DEV Community

Discussion on: 🛑 STOP thinking about React lifecycle methods.

 
swastikyadav profile image
Swastik Yadav • Edited

Wow, this is really very insightful. I will give this a thorough study.

Thanks for sharing this.

And thanks for starting this positive and constructive conversation.

😊

Thread Thread
 
z2lai profile image
z2lai • Edited

This short and succinct article was one of the most enlightening ones I've read about the useEffect hook. I've subscribed to your Youtube channel and newsletter, can't wait to see more from you!

It can't be a coincidence that you wrote this just a few days after David Khourshid's (creator of XState library) talk about this exact topic, which include the same insights in this comment thread. If you haven't checked it out, you really should as I believe you'll benefit a lot from it, and many of David's talks: youtube.com/watch?v=HPoC-k7Rxwo

His conclusion is the same as Luke's - avoid useEffect hook as side-effects should be considered as part of state management ([state, event]=>[nextState, effects]) and not separately, which is what external libraries help you do. This is one of the things that David's own XState library does on top of implementing a declarative and explicit way of managing state with State Machines. You should also check out his talks on state machines and his XState library.

Thread Thread
 
swastikyadav profile image
Swastik Yadav

Thanks for all your support.

I will surely check David Khourshid's talk on this topic.