Created
March 8, 2021 09:57
-
-
Save sobstel/8b1b58dfe0b2f425d0850cb0f22a92c5 to your computer and use it in GitHub Desktop.
react-native-animatable unmount animation with hooks
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
// https://github.com/oblador/react-native-animatable/issues/132#issuecomment-786870602 | |
const MyComponent = (props) => { | |
const ref = React.useRef(); | |
React.useEffect(() => { | |
ref?.current?.fadeIn(); | |
return () => ref?.current?.fadeOut(); // as you know, this is the same as unmount ;) | |
}, [props.id]); // track some prop that changes | |
return ( | |
<Animatable.View ref={ref}> | |
<View> | |
...stuff | |
</View> | |
</Animatable.View> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment