kitze / custom-react-scripts

[DEPRECATED, use customize-cra] Allow custom config for create-react-app without ejecting
https://custom-react-scripts.netlify.com
MIT License
993 stars 97 forks source link

Bug: babel rejects class properties #156

Open fabdrol opened 5 years ago

fabdrol commented 5 years ago

I have a react component which looks like this:

class SignIn extends React.Component {
  state = {
    username: '',
    password: '',
    remember: false
  }

  usernameChange = (e) => {
    this.setState({ username: e.target.value })
  }

  passwordChange = (e) => {
    this.setState({ password: e.target.value })
  }

  render () { /* ... */ }
}

The included babel parser causes a compile error:

Failed to compile.

./src/components/login/login.js
  Line 57:  'state' is not defined           no-undef
  Line 63:  'usernameChange' is not defined  no-undef
  Line 67:  'passwordChange' is not defined  no-undef

Search for the keywords to learn more about each error

I'm having trouble figuring out what's going wrong here. My env file:

REACT_APP_DECORATORS = true
REACT_APP_BABEL_STAGE_0 = true

REACT_APP_SASS = false
REACT_APP_LESS = false
REACT_APP_STYLUS = true

REACT_APP_CSS_MODULES = true
REACT_APP_SASS_MODULES = false
REACT_APP_STYLUS_MODULES = true
REACT_APP_LESS_MODULES = false
REACT_APP_WEBPACK_DASHBOARD = false

# CSS Module hash
# REACT_APP_CSS_MODULE_CLASSNAME_TEMPLATE = 'module-[sha512:hash:base32]-[name]-[local]'