Skip to content

Trying to turn the Edit function into a class to be able to use React lifecycle methods #36929

Answered by fabio-blanco
fabio-blanco asked this question in Q&A
Discussion options

You must be logged in to vote

It turned out that, at least for my specific use case, there was no need to use a class or interact with React lifecycle methods. My code was already working with the component as a function but for some reason I wasn't able to see it in that moment.
I have probably made a mistake while testing.

But I've made some research an discovered that the guys at React have an argument against using class in javascript. To address things that could just be done through classes in the past they have created the hooks functionality to be used by functional React components.
If you have the need to interact with the React state, take a look at the new state hook as everything seems to be functional no…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Lovor01
Comment options

Answer selected by fabio-blanco
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants