Last active
March 14, 2020 14:27
-
-
Save hitrik/4039b73ebb0f8dce12d904930fa76094 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
const useAnimationUnmount = (duration = 300, useNativeDriver = true) => { | |
const [animation] = useState(() => new Animated.Value(1)); | |
const [unmount, setUnmount] = useState(false); | |
const start = useCallback( | |
() => | |
Animated.timing(animation, { | |
toValue: 0, | |
useNativeDriver, | |
duration, | |
}).start(function onFinish() { | |
setUnmount(true); | |
}), | |
[] | |
); | |
return [start, unmount, animation]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment