Created
May 8, 2019 05:42
-
-
Save gaperton/629d91f59dadd088323d86f688ad3674 to your computer and use it in GitHub Desktop.
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 function useSafeLink( initialState ){ | |
const $value = useLink( initialState ), | |
isMounted = useIsMountedRef(); | |
const { set } = $value; | |
$value.set = x => isMounted.current && set( x ); | |
return $value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment