How to convert 'Functional Componenet' to 'Class Component' in React?

how to convert units in physics
how to convert units of measurement easily
how to convert units in chemistry
how to convert metric units
how to convert cm to m
how to convert si units
conversion chart
unit conversion table

I would like to convert this Functional Component

import React from 'react';
import logo from './logo.svg';
import './App.css';
import { makeStyles } from '@material-ui/core/styles';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import Typography from '@material-ui/core/Typography';
import Button from '@material-ui/core/Button';
import IconButton from '@material-ui/core/IconButton';
import MenuIcon from '@material-ui/core/Menu';
import FacebookLoginButton from "./components/FacebookLoginButton"

const useStyles = makeStyles(theme => ({
  root: {
    flexGrow: 1,
  },
  menuButton: {
    marginRight: theme.spacing(2),
  },
  title: {
    flexGrow: 1,
  },
}));

function App() {
  const classes = useStyles();
  return (
    <div className="App">
      <AppBar position="static">
        <Toolbar>
          <IconButton edge="start" className={classes.menuButton} color="inherit" aria-label="menu">
            <MenuIcon />
          </IconButton>
          <Typography variant="h6" className={classes.title}>
            Tiket.hu
          </Typography>
          <Button color="inherit">Search</Button>
          <Button color="inherit">Basket</Button>
          <FacebookLoginButton/>
        </Toolbar>
      </AppBar>
    </div>
  );
}

export default App;

to Class Component, like below here, but I get an error. Do you know what is wrong?

import React, { Component } from "react";
import logo from './logo.svg';
import './App.css';
import { makeStyles } from '@material-ui/core/styles';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import Typography from '@material-ui/core/Typography';
import Button from '@material-ui/core/Button';
import IconButton from '@material-ui/core/IconButton';
import MenuIcon from '@material-ui/core/Menu';
import FacebookLoginButton from "./components/FacebookLoginButton"

const useStyles = makeStyles(theme => ({
  root: {
    flexGrow: 1,
  },
  menuButton: {
    marginRight: theme.spacing(2),
  },
  title: {
    flexGrow: 1,
  },
}));

class App extends Component {
    classes = useStyles();
    render() {
      return <div className="App">
        <AppBar position="static">
          <Toolbar>
            <IconButton edge="start" className={this.classes.menuButton} color="inherit" aria-label="menu">
              <MenuIcon />
            </IconButton>
            <Typography variant="h6" className={this.classes.title}>
              Tiket.hu
            </Typography>
            <Button color="inherit">Search</Button>
            <Button color="inherit">Basket</Button>
            <FacebookLoginButton/>
          </Toolbar>
        </AppBar>
      </div>;
    }
}

export default App;

Do you know what is wrong? How should I convert differently?

You must use the material ui HOC with a class component

import React, { Component } from "react";
import logo from './logo.svg';
import './App.css';
import { makeStyles } from '@material-ui/core/styles';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import Typography from '@material-ui/core/Typography';
import Button from '@material-ui/core/Button';
import IconButton from '@material-ui/core/IconButton';
import MenuIcon from '@material-ui/core/Menu';
import FacebookLoginButton from "./components/FacebookLoginButton"

// import this
import { withStyles } from '@material-ui/core/styles';

// make this
const styles = theme => ({
  root: {
    flexGrow: 1,
  },
  menuButton: {
    marginRight: theme.spacing(2),
  },
  title: {
    flexGrow: 1,
  },
})

class App extends Component {
    render() {
      return <div className="App">
        <AppBar position="static">
          <Toolbar>
            <IconButton edge="start" className={this.props.classes.menuButton} color="inherit" aria-label="menu">
              <MenuIcon />
            </IconButton>
            <Typography variant="h6" className={this.props.classes.title}>
              Tiket.hu
            </Typography>
            <Button color="inherit">Search</Button>
            <Button color="inherit">Basket</Button>
            <FacebookLoginButton/>
          </Toolbar>
        </AppBar>
      </div>;
    }
}

export default withStyles(styles)(App);

Converting Units With Conversion Factors, This video focuses on converting units of measurement with conversion factors. It explains how Duration: 20:03 Posted: Jun 10, 2017 FreeConvert.com is a free online file conversion tool to convert your files (image, video, document, and music) from one format to another. Choose a target format above, it will take you to the file upload page. Your files are instantly converted once you upload them to our servers. There is no software to download/install.

Material-ui MakeStyles is using the hook pattern, which is not allowed inside class components. Use withStyles HOC instead.

import { withStyles } from '@material-ui/core/styles';

const styles = {
  root: {
    flexGrow: 1,
  },
  menuButton: {
    marginRight: theme.spacing(2),
  },
  title: {
    flexGrow: 1,
  },
};

class App extends Component {
    const { classes }  = this.props;
    the rest of your component...
}

export default withStyles(styles)(App);

How to convert units, Learn how to convert any unit of measure in this step by step example. To see all my videos Duration: 6:44 Posted: Jul 2, 2013 Of course, expect the actual temperature to be a few degrees off,but for the most part, this is a reliable and easy way to convert temperatures in your head fast. If you want to convert Fahrenheit to Celsius, do the opposite: subtract 30 from the temperature in degrees Fahrenheit, and then divide by 2to get the temperature in degrees Celsius.

You are using hooks inside a Class Component this isn't allowed. Hooks are specifically made to work with Functional Components

How to Convert Units - Unit Conversion Made Easy, "The most entertaining unit conversion video ever made!" This tutorial demonstrates the basics Duration: 4:01 Posted: Sep 14, 2009 If the decimal number has a fractional part, then the fractional parts are converted into binary by multiplying it by 2. Only the integer part of the result is noted. Repeat the multiplication until the fractional part becomes 0. Eg. 0.75 is the number we want to convert, so we'll start multiplying it by 2. 0.75 *2=1.50.

3 Ways to Convert Units, How to Convert Units. With all of the different measuring systems in the world, converting units Duration: 12:46 Posted: Feb 11, 2020 Open Start. Click the Windows logo in the bottom-left corner of the screen. The Start menu will pop up. Alternatively, if you have a picture that you want to convert on your desktop or in another similarly accessible location, right-click the picture, select Open with, and click Photos to open the picture in the Photos app.

How to Convert Units of Measurement, If you want to convert 60 miles to kilometers, the conversion factor is 1.61, but do you multiply or divide? Everybody finds these questions� To convert a JPG file into a PDF, start by opening the “Start” menu and selecting photos if you’re working on a Windows computer. Then, click “Select” and choose the JPG file you want to change.

Conversion between metric units (video), What do I do if the conversion is between Km and Miles? Reply.Duration: 5:16 Posted: Jul 21, 2011 Convert definition is - to bring over from one belief, view, or party to another. How to use convert in a sentence. Synonym Discussion of convert.

Comments
  • "You can’t use Hooks inside of a class component, ..." Source . You still try to use useStyles().
  • Hi! Where I can learn more about this expression? export default withStyles(styles)(App); withStyles is a method, and styles and App are parameters? Sorry I am newbie in Node.js, React. :D
  • Hi! If I put const { classes } = this.props; out of render() I get an error. Shall I put in render()? But then I do not need this. in this.classes.title right?
  • Oh yes you can remove this and just use classes.title or this.props.classes.title