DEV Community

Nwanguma Victor
Nwanguma Victor

Posted on

The Class Property Proposal is Finished and Avaliable in React

Hooray! The class property proposal is finished and is avaliable via babel/plugin-proposal-class-properties

This plugin is included in @babel/preset-env, in ES2022

Check it out here

So you can finally clean that legacy React project in peace

class Foo extends React.Component {
  // Note: this syntax is now standardized.
  handleClick = () => {
    console.log('Click happened');
  }
  render() {
    return <button onClick={this.handleClick}>Click Me</button>;
  }
}

Enter fullscreen mode Exit fullscreen mode

Spread the word!

Top comments (0)