Skip to content

Instantly share code, notes, and snippets.

@shuding
Created July 6, 2021 14:29
Show Gist options
  • Save shuding/fc665aa848cfab68dd8382172cc3306f to your computer and use it in GitHub Desktop.
Save shuding/fc665aa848cfab68dd8382172cc3306f to your computer and use it in GitHub Desktop.
function useWhyDoesItRerender(obj: any) {
for (let k in obj) {
useEffect(() => {
console.log('Value', k, 'changed to', obj[k]);
}, [obj[k]]);
}
}
// useWhyDoesItRerender({ propA, propB, stateC })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment