Created
October 3, 2019 13:06
-
-
Save lukebrandonfarrell/c2b9534a22688dcc60a0e622107b1012 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 counterValue = 0; | |
const initialCounterValue = useInitialValue(selectedBrands); | |
const hasCounterChanged = counterValue !== initialCounterValue; |
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
/** | |
* Use initial value | |
* | |
* @param value | |
* | |
* @return {*} | |
*/ | |
export function useInitialValue(value) { | |
const initialValue = useRef(null); | |
useEffect(() => { | |
initialValue.current = value; | |
}, []); | |
return initialValue.current; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment