1
votes

I try to run last one example in App Bar demo, And I got error:

ERROR in ./src/Root.js
Module build failed: SyntaxError: Unexpected token (28:8)
  26 | 
  27 | class MenuAppBar extends React.Component {
> 28 |   state = {
     |         ^
  29 |     auth: true,
  30 |     anchorEl: null,
  31 |   };

Part of the code

class MenuAppBar extends React.Component {
  state = {
    auth: true,
    anchorEl: null,
  };

  handleChange = (event, checked) => {
    this.setState({ auth: checked });
  };

  handleMenu = event => {
    this.setState({ anchorEl: event.currentTarget });
  };

  handleClose = () => {
    this.setState({ anchorEl: null });
  };

dependencies

  • "material-ui": "^1.0.0-beta.30"
  • "react": "^16.2.0"
  • "react-dom": "^16.2.0"
  • "babel-cli": "^6.26.0"
  • "babel-core": "^6.26.0"
  • "babel-loader": "^7.1.2"
  • "babel-preset-env": "^1.6.1"
  • "babel-preset-es2017": "^6.24.1"
  • "babel-preset-react": "^6.24.1"
  • "webpack": "^3.10.0"

.babelrc

{
    "presets": ["env","react"]
}

How can I run it?

1
This is an exact duplicate of this post.Jules Dupont

1 Answers

1
votes

I would inspect a bit into the presets listed inside MUI's GitHub repo in here:

https://github.com/mui-org/material-ui/blob/v1-beta/.babelrc

Maybe some of the other presets are required for you to run it like this. Also check if you are running the required plugin for object assign which they are using as well