Last active
May 13, 2019 16:25
-
-
Save gaperton/dde32204223de2fa38926d06e1bff38a 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
function useBoundLink( source ){ | |
// If the source is another Link, extract the value out of it. | |
const value = source instanceof Link ? source.value : source, | |
link = useLink( value ); | |
// If the value changes, execute link.set( value ) after the render. | |
useEffect(() => link.set( value ), [ value ]); | |
return link; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment