I am using react-transition-group's tag to create animations between routes using react-router-v4. I am using tags to switch between routes in my code based off of changes in state. The issue that I am running into is, when a is triggered, the component immediately unmounts, before giving the exit animation time to play out. The new route animates in correctly.
I have tried to solve this by following this page on the React Transition Group site: https://reactcommunity.org/react-transition-group/with-react-router
It acknowledges the problem that I am having with the components immediately unmounting, but my solution does not seem to be working.
const routes = [
{ path: '/', name: 'Dashboard', Component: Dashboard },
{ path: '/detailedview', name: 'DetailedView', Component: DetailedView },
{ path: '/dashboardloop', name: 'DashboardLoop', Component: DashboardLoop },
]
function Example() {
return (
<Router>
<>
<Container className="container">
{routes.map(({ path, Component }) => (
<Route key={path} exact path={path}>
{({ match }) => (
<CSSTransition
in={match != null}
timeout={500}
classNames="page"
unmountOnExit
>
<div className="page">
<Component />
</div>
</CSSTransition>
)}
</Route>
))}
</Container>
</>
</Router>
)
}
ReactDOM.render((
<Example/>
), document.getElementById('root'));
Any help would be appreciated with this! Thank you