Created
January 29, 2019 21:43
-
-
Save ericvicenti/fb59dac4f7d7e57254e0eab1bf043950 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
import Animated from 'react-native-reanimated'; | |
const defaultApplyValue = (v, dest) => v.setValue(dest); | |
export default function useAnimatedValue(currentValue, applyValue = defaultApplyValue) { | |
const [val] = useState(new Animated.Value(currentValue)); | |
useEffect( | |
() => { | |
applyValue(val, currentValue); | |
}, | |
[currentValue], | |
); | |
return val; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment