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 ES2022Check 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>;
}
}
Spread the word!
Top comments (0)