When an instance of a component is being created and inserted into the DOM.
- A special type of function that will get called whenever a new component is created.
- Used to initialize states & Binding events.
- Not perform, Http req.
- When the state of component depends on change in props.
- set the state.
- Not perform, Http req.
- Only Required Method.
- Return JSX.
- Children component Lifecycle methods also get execute.
- Not perform, Http req.
- Invoked immediately after a component and its child components have been rendered to DOM.
- Perform any AJAX call to load data.
When a component is being re-render as a result of changes to either its props or state.
- Only Required Method
- Return JSX
- Not perform, Http req.
- called after the render is finished in the re-render cycles.
When a component is being removed from the DOM.
- Method is invoked immediately before a component is unmounted and destroyed.
- Cancelling any network req., also invalidating timers.
- Do Not Call The SetState Method.
example - constructor(props){ super(props); this.state = {name:''} }
example - const [name,SetName]= React.useState('')