Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

React Component Lifecycle

What is the order that Class components run when React initialize and mounts 
the components.

1. Regardless of React Components, constructors are always ran first 
	1. In constructor, you will just initialize the state in constructor
2. Render runs second, which determines what to show. This is the template 
   of the HTML and dictates the UI is going to be.
3. Third one that runs is componentDidMount, React runs the constructor, 
   runs the render and mounts the initial state and mounts on. Then it 
   will runs the code in componentDidMount();
   
- When setState() is called, the render() method will be called again and 
  re-renders.
	- Every subsequent child with a different props will also be re-rendered.
Source by reactjs.org #
 
PREVIOUS NEXT
Tagged: #React #Component #Lifecycle
ADD COMMENT
Topic
Name
1+8 =