useWhyDidYouUpdate()
The
useWhyDidYouUpdate() hook is a dev-tool utility that helps you understand why a component re-rendered by comparing previous and current props.Import
typescript
Usage
Note: Open your browser console (F12) to see the logs generated by this demo.
Watched Component
count: 0
userId: 1
(Check console to see the logs)
Component.tsx
API
Arguments
name– string A label to identify the component in the console logs.props– Record<string, any> The props object (passpropsdirectly).