Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lifecycle methods in react

Tags:

reactjs

Is it possible (and is it OK) to use fat arrow functions for Lifecycle methods in React?

componentWillMount = () => { }

My IDE shows it is incorrect, but I saw in different application

like image 398
Yaks10 Avatar asked Mar 10 '26 16:03

Yaks10


1 Answers

You technically can do it but there is really no reason to do so. It may even hurt performance as it will not be included in the prototype and can therefore not be reused.

Also see this issue in the react github repo where the same question was asked.

like image 74
trixn Avatar answered Mar 12 '26 12:03

trixn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!