Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't support arrow function in class. #7

Open
ghost opened this issue Jul 1, 2019 · 1 comment
Open

Can't support arrow function in class. #7

ghost opened this issue Jul 1, 2019 · 1 comment

Comments

@ghost
Copy link

ghost commented Jul 1, 2019

I got below error. It doesn't support arrow function in class.

SyntaxError: src/Test/Components/Footer.js: Unexpected token (38:11)
36 | }
37 |

38 | toggleTc = () => {
| ^
39 | this.setState({
40 | tcModal: !this.state.tcModal,
41 | });

@drewandre
Copy link

drewandre commented Jan 9, 2020

You need to add @babel/plugin-proposal-class-properties to your .babelrc file:

  "env": {
    "development": {
      "presets": [
        "@babel/env"
      ],
      "plugins": [
        "@babel/plugin-proposal-class-properties"
      ]
    },
    "production": {
      "presets": [
        "@babel/preset-react",
        "@babel/env",
        [
          "minify", {
            "builtIns": false
          }
        ]
      ],
      "plugins": [
        "transform-remove-console",
        "@babel/plugin-proposal-class-properties"
      ]
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant