What is the difference between componentWillMount and componentDidMount?
|This is called only once during the component lifecycle immediately before the component is rendered to the server. It is used to assess props and do any extra logic based upon them.||It is called only on the client end, meaning, it is usually performed after the initial render when a client has received data from the server.|
|Used to perform state changes before the initial render.||It allows you to perform all kinds of advanced interactions including state changes.|
|No way to “pause” rendering while waiting for the data to arrive.||It can be used to set up long-running processes within a component.|
|It is invoked just immediately after the mounting has occurred.||Putting the data loading code in this just ensures that data is fetched from the client's end.|
|Users should avoid using any async initialization in order to minimize any side-effects or subscriptions in this method.||Here, the data does not load until the initial render is done. Hence, users must set an initial state properly to eradicate undefined state errors.|
Suggest An Answer
No suggestions Available!