Wednesday, December 1, 2021

Use componentDidMount in React.js




Reference:

https://reactjs.org/tutorial/tutorial.html

componentDidMount is called exactly once and when The component has been initialized. The component has bind with the container element and rendered successfully. All the properties and initial states has been initialized. You can now call setState and other component function on this component, manipulate it and so on. Simply it is the starting point for you to interact with it.

componentDidMount is useful  for AJAX requests. 

componentDidMount() executes after the render() at first execution. After that it executes before the render() according to React Lifecycle.

No comments:

Post a Comment