In What order react lifecycle methods execute.
React execution flows of lifecycle methods
Constructor()
It helps to set up an initial state of the component.
Render()
It renders an initial state with the use of constructor
After these two methods React Lifecycle methods stars executing
ComponentDidMount()
After render methods are done. It looks for this method and mounts the component. In this method, you can make an API call, create an Ajax request etc.
ComponentDidUpdate()
This method runs whenever your component state changes or when the component receives an update.
ComponentWillMount()
This has been deprecated in version 16.4 and removed completely from version 17.
ComponentWillUnmount()
Invokes whenever a component is removed from the DOM. i.e. If you use react router and changes the route then it will call this method.
You don't need to physically bind these methods as react does it for you
Top comments (0)