Which babel preset to get () => for this binding in class methods?

such as:

class Jumbotron extends React.Component {
 getContent = () => {
    return <h>Need Some Help?</h1>;
  }
  render(){
    return (
          <div>
            {this.getContent()}
          </div>
    );
  }
}

without .bind(this) or a constructor?

Do a meteor npm install --save-dev babel-plugin-transform-class-properties and then add

"babel": {
    "plugins": ["transform-class-properties"]
}

to your package.json.

1 Like