Skip to content

Instantly share code, notes, and snippets.

@197291
Created January 9, 2019 08:57
Show Gist options
  • Save 197291/3eee1baf0f328d3eb36f54db6375b121 to your computer and use it in GitHub Desktop.
Save 197291/3eee1baf0f328d3eb36f54db6375b121 to your computer and use it in GitHub Desktop.
CheckChanges ComponentDidUpdate, ComponentWillReceiveProps
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