title: Unexpected token - react/js
body: <p>I'm trying to run a project, but the same is displaying an error in the console related to a function I have, the error is as follows:</p>
  
  <p>"63:25 error Parsing error: Unexpected token, expected (function toggleDrawer = (open) => () => {^ state = {"</p>
  
  <p>My project is this:</p>
  
  <pre><code>import React from 'react';
  import PropTypes from 'prop-types';
  import { Link } from 'react-router-dom';
  import { withStyles } from 'material-ui/styles';
  import AppBar from 'material-ui/AppBar';
  import Drawer from 'material-ui/Drawer';
  import Button from 'material-ui/Button';
  import IconButton from 'material-ui/IconButton';
  import Toolbar from 'material-ui/Toolbar';
  import MenuIcon from 'material-ui-icons/Menu';
  import TextField from 'material-ui/TextField';
  import Paper from 'material-ui/Paper';
  import Grid from 'material-ui/Grid';
  import '../assets/scss/main.scss';
  import img from '../assets/images/react.png';
  
  const styles = theme =&gt; ({
    root: {
      width: '100%',
    },
    flex: {
      flex: 1,
    },
    menuButton: {
      marginLeft: -12,
      marginRight: 20,
    },
    inputProps: {
      step: 300,
    },
    button: {
      margin: theme.spacing.unit,
    },
    input: {
      display: 'none',
    },
    paper: {
      padding: 50,
      textAlign: 'center',
      border: '5px solid black',
      width: '100%',
    },
    paper1: {
      backgroundColor: 'red',
      marginTop: '13%',
    },
    img: {
      width: '45%',
    },
    appbar: {
      marginLeft: '-20.20%',
      marginTop: '-20%',
      width: '139.99%',
    },
  });
  
  function ButtonAppBar(props) {
    const { classes } = props;
    const state = {
      inputs: {},
    };
  
    function toggleDrawer = (open) =&gt; () =&gt; {
  
        state={
  
          open:false,  
        };
      this.setState({
        open,
      });
    };
  
    const updateInputValue = (evt) =&gt; {
      state.inputs[evt.target.name] = evt.target.value;
      console.log(state.inputs);
    };
  
    const handleSubmit = (event) =&gt; {
      // console.log('handleSubmit', username, password);
      if (!event.target.checkValidity()) {
        console.log({ displayErrors: true });
      }
      event.stopPropagation();
      event.preventDefault();
      return 0;
    };
    return (
      &lt;div className={styles.root}&gt;
        &lt;Grid container spacing={8} alignItems="center" justify="center"&gt;
          &lt;Paper className={classes.paper}&gt;
            &lt;AppBar position="static" className={classes.appbar}&gt;
              &lt;Toolbar&gt;
                &lt;IconButton onClick={this.toggleDrawer(true)} className={classes.menuButton} color="contrast" aria-label="Menu"&gt;
                &lt;Drawer open={this.state.open} onClose={this.toggleDrawer('open', false)}&gt;
                onClick={this.toggleDrawer('open', false)}
                &lt;/Drawer&gt;
                  &lt;MenuIcon /&gt;
                &lt;/IconButton&gt;
              &lt;/Toolbar&gt;
            &lt;/AppBar&gt;
            &lt;img src={img} alt="React" className={classes.img} /&gt;&lt;br /&gt;
            &lt;form onSubmit={handleSubmit} noValidate&gt;
              &lt;TextField id="email" type="email" label="Usuário" className={classes.user} value={state.inputs.username} onChange={evt =&gt; updateInputValue(evt)} /&gt;&lt;br /&gt;
              &lt;TextField id="password" type="password" label="Senha" className={classes.senha} value={state.inputs.password} onChange={evt =&gt; updateInputValue(evt)} /&gt;
              &lt;AppBar position="static" className={classes.paper1}&gt;
                &lt;Link to="/Orders"&gt;
                  &lt;Button type="submit" color="contrast"&gt;Login&lt;/Button&gt;
                &lt;/Link&gt;
              &lt;/AppBar&gt;
            &lt;/form&gt;
          &lt;/Paper&gt;
        &lt;/Grid&gt;
      &lt;/div&gt;
    );
  }
  
  ButtonAppBar.propTypes = {
    classes: PropTypes.object.isRequired,
  };
  
  export default withStyles(styles)(ButtonAppBar);
  </code></pre>
  
  <p>I wonder why this error is happening (I am a beginner in react).</p>