Last active
February 5, 2021 07:24
-
-
Save InfiniteXyy/bafa9574dca0f2097e21251204685257 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const whyChangeRef = React.useRef({}) | |
React.useEffect(() => { | |
console.log('why am i rendered?') | |
Object.keys(props).forEach((key) => { | |
const before = whyChangeRef.current[key] | |
const current = props[key] | |
if (before !== current) { | |
console.log(key + ' changed', [before, current]) | |
} | |
}) | |
whyChangeRef.current = props | |
}, Object.values(props)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment