React Core & Hooks (407 Qs)•Part 9: React Hooks Deep Dive (262 - 316)
How to listen to state changes?
mid LevelCode ExampleHooks
The componentDidUpdate lifecycle method will be called when state changes. You can compare provided state and props values with current state and props to determine if something meaningful changed.
csharp
componentDidUpdate(object prevProps, object prevState)
csharp
**Note:** The previous releases of ReactJS also uses `componentWillUpdate(object nextProps, object nextState)` for state changes. It has been deprecated in latest releases.