Created
August 28, 2019 15:01
-
-
Save VadimBrodsky/b485d501067c230f15ac6803c22fc700 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 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