What is componentDidUpdate lifecycle method?
The componentDidUpdate() method allows us to execute the React code when the component is updated. All the network requests that are to be made when the props are passed to the component changes are coded here.
Syntax:
componentDidUpdate(prevProps, prevState, snapshot)
- prevProps: Previous props passed to the component
- prevState: Previous state of the component
- snapshot: Value returned by getSnapshotBeforeUpdate() method
What is the purpose of the componentDidUpdate lifecycle method ?
React web apps are actually a collection of independent components that run according to the interactions made with them. Every React Component has a lifecycle of its own, the lifecycle of a component can be defined as the series of methods that are invoked in different stages of the component’s existence.
Contact Us