I have seen some tutorials on youtube about lifecycle hooks, they all explained same thing in different ways but I have a question that how to use them effectively and what is the alternative of these hooks?
I may not got the real concept of these hooks so can someone suggest me any tutorial with good examples?
Thanks Pradhumn Sharma
Check out this video, it's a quiz game using Pokemon to guess lifecycles and their purpose:
Sebastian
Basically it’s about the state of the whole component. I searched for a fitting image but found also this article quite explaining.
levelup.gitconnected.com/componentdidmakesense-re…
For instance if you want to call an api and load data only on the first apprentice of an component then you use componentDidMount. If you have to clean up references (Timer or some external ones) use componentWillUnmount. I think you get the point. There is a method for every state of a component can get through.
Since the component is communicating about its state in the circle of life through these methods there’s no alternative to them. Other frameworks have similar paradigms.
For completion here are the official docs
reactjs.org/docs/state-and-lifecycle.html