React is an open-source front-end JavaScript library that is used for building user interfaces, especially for single-page applications. It is used for handling view layer for web and mobile apps. React was created by Jordan Walke, a software engineer working for Facebook. React was first deployed on Facebook's News Feed in 2011 and on Instagram in 2012.
example - constructor(props){ super(props); this.state = {name:''} }
example - const [name,SetName]= React.useState('')
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.
- Method is called every time a component is re-rendered.
- set the state
- Not perform, Http req.
- Dictates if the component should re-render or not.
- Performance Optimization
- Not perform, Http req.
- Only Required Method
- Return JSX
- Not perform, Http req.
- Called right before the changes from the virtual DOM are to be reflected in the DOM.
- Capture some Information From DOM.
- 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.