Skip to content

Instantly share code, notes, and snippets.

@VadimBrodsky
Created August 28, 2019 15:01
Show Gist options
  • Save VadimBrodsky/b485d501067c230f15ac6803c22fc700 to your computer and use it in GitHub Desktop.
Save VadimBrodsky/b485d501067c230f15ac6803c22fc700 to your computer and use it in GitHub Desktop.
const hasChange = (prevState: RootState, newState: RootState): ((prop: string) => boolean) => (
propertyPath: string,
): boolean => {
const path = propertyPath.split('.');
try {
const oldProp = path.reduce((prop): unknown => prevState[prop], prevState);
const newProp = path.reduce((prop): unknown => newState[prop], prevState);
return oldProp === newProp;
} catch (e) {
return false;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment