Last active
April 11, 2020 23:54
-
-
Save paigen11/fcf1a4a7719e4fbbab7efb3a4a74ad64 to your computer and use it in GitHub Desktop.
Simple demo code example using React Transition Group's transition component
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
import { Transition } from "react-transition-group"; | |
const duration = 500; | |
const defaultStyle = { | |
transition: `opacity ${duration}ms ease-in-out`, | |
opacity: 0, | |
}; | |
const transitionStyles = { | |
entering: { opacity: 0.5 }, | |
entered: { opacity: 1 }, | |
exiting: { opacity: 0.5 }, | |
exited: { opacity: 0 }, | |
}; | |
const Fade = ({ in: inProp }) => ( | |
<Transition in={inProp} timeout={duration}> | |
{state => ( | |
<div | |
style={{ | |
...defaultStyle, | |
...transitionStyles[state], | |
}} | |
> | |
This is Fade Transition sample code! | |
</div> | |
)} | |
</Transition> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment