Created
October 31, 2018 14:57
-
-
Save jorgeortega/21c73a1068b6a2a397187bd0fdb4f943 to your computer and use it in GitHub Desktop.
Minimal transition using React Transition and styled-components
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 Transition from 'react-transition-group/Transition' | |
<Transition in={isVisible} timeout={200}> | |
{(state) => ( | |
<StyledComponent transitionState={state} /> | |
)} | |
</Transition> | |
const StyledComponent = styled.div` | |
transition: opacity 0.2s; | |
opacity: ${({ transitionState }) => (['entering', 'entered'].includes(transitionState)) ? '1' : '0'}; | |
` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment