In this post let's talk about the paradigm shift from lifecycle methods to state synchronization and hooks in ReactJs.
When class components were ...
For further actions, you may consider blocking this person and/or reporting abuse
Ah! Now I got your point. Now I see where you coming from.
I missUnderstood your point of miss-using the useEffect hook.
Well, the whole point to ReactJs is to keep the UI and State in sync. And useEffect is the most commonly used hook to handle side-effects in ReactJs community.
useEffect can create performance issue without dependency array, but with dep array, I think it works just fine.
Would love to know your view on this, if you are ok to elaborate your point a little bit more.
Thank You 🙏
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.
😊
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.
Thanks for all your support.
I will surely check David Khourshid's talk on this topic.
Agreed
So, how would you go about making an API call, based on the response of which your view will be rendered.
As per my React knowledge useEffect is the only way here.
Please share if it can be done without useEffect.
Nicely explained!
Thanks for the kind words K-Sato 😊
Thank you for clearing it up!
My pleasure... 🙏
Nice article.
Thank you, Andrew 😊
ReactJs is a popular front-end development framework that has seen a lot of growth in the past few retro bowl years. It's easy to use and has a lot of features, making it a great choice for web applications and apps.