Created
January 9, 2019 08:57
-
-
Save 197291/3eee1baf0f328d3eb36f54db6375b121 to your computer and use it in GitHub Desktop.
CheckChanges ComponentDidUpdate, ComponentWillReceiveProps
This file contains hidden or 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
export const checkChangesDidUpdate = (prevProps: any, prevState: any, curProps: any, curState: any) => { | |
(Object as any).entries(curProps).forEach(([key, val]) => | |
prevProps[key] !== val && console.log(`Prop '${key}' from ${prevProps[key]} to ${curProps[key]} changed`) | |
); | |
(Object as any).entries(curState).forEach(([key, val]) => | |
prevState[key] !== val && console.log(`State '${key}' from ${prevState} to ${curState} changed`) | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment