33
loading...
This website collects cookies to deliver better user experience
Class Component:-
A Class component requires you to extends from React.Components and create a Render function that returns a React Element. A class component is called as statefull class component. Whenever the state of the components changes the render method will call.
Functional Component:-
A Functional component accepts props as an argument and returns a React Element. There is no render method used in funtional component. A function component is called as stateless functional component. It render the user interface based on props.
Mounting:-
Mounting means putting elements into the DOM.
React has four methods that gets called in the given order, when we mount a component:-
constructor()
getDerivedStateFromProps()
render()
componentDidMount()
Updating:-
A component is updated whenever there is a change in the component's state or props.
React has five methods that gets called in the given order when a component is updated:-
getDerivedStateFromProps()
shouldComponentUpdate()
render()
getSnapshotBeforeUpdate()
componentDidUpdate()
Unmounting:-
when a component is removed from the DOM, or unmounting as React likes to call it.
React has only one ethod that gets called when a component is unmounted:-
componentWillUnmount()