I'm trying to have a component conditionally render in React and slide it when it does render
packages:
"react": "^16.8.6",
"react-transition-group": "^4.0.1",
code snippet:
{ expanded && (
<CSSTransition in={expanded} timeout={500} classNames="slide">
<div className="expandedDiv"></div>
</CSSTransition>
)}
css:
.slide-enter {
transform: translateX(-100%);
transition: .3s linear;
}
.slide-enter-active {
transform: translateX(0%);
}
.slide-exit {
transform: translateX(0%);
transition: .3s linear;
}
.slide-exit-active {
transform: translateX(-100%);
}
structure:
+------------------------------+
| | | header |
| | |____________+
| | | content |
| | | |
| | | |
| nav | expanded | |
| | | |
| | | |
| | | |
+------------------------------+
Expanded should slide in on true, and slide out on false, it is expandedDiv
from the code snippet
The div just pops in with no animation. Expected behaviour is a linear transition from left to right
Thanks