3

I searched this issue but I could not find a solution with native react-transition-group.

I have 2 components Home and Order. I use route transition for these. Everything works fine for these flat routes.

<TransitionGroup component={null}>
        <CSSTransition
            key={props.locationKey}
            classNames={["route-slide"].join(' ')}
            timeout={{ enter: 1000, exit: 500 }}>
            <div>
            <Switch key={this.props.location.pathname} location={this.props.location}>
                <Route path="/home" component={Home} /> 
                <Route path="/order" component={Order} />
                <Route path="*" render={({ location }) => {
                                if (location.pathname === window.location.pathname) {
                                    return <Redirect to="/home" />;
                                }
                                return null;
                            }} />
.
.
.

I want to use route transition for sub routes in Home component. But always Home component is animated when I want to animate sub routes. You can find sub routes below.

<TransitionGroup component={null}>
            <CSSTransition
                key={props.locationKey}
                classNames={["route-slide"].join(' ')}
                timeout={{ enter: 1000, exit: 500 }}>
                <div>
                <Switch key={this.props.location.pathname} location={this.props.location}>
                    <Route path="/home" exact render={() => {
                                    return <Navigations/>;
                                }} />

                    <Route path="/home/:type" component={SomeComponentByType} />
                </Switch>
.
.
.

This is the image for Home Component.

enter image description here

How can I animate just sub routes?

Thanks for any helps

baris usanmaz
  • 839
  • 1
  • 13
  • 31
  • Have you succeed since your post? If yes how have you done it? Here a link related to your former demand: https://stackoverflow.com/questions/45478148/page-transitions-and-component-animation-in-reactjs – Webwoman Feb 18 '19 at 10:47
  • also searching for answer and I have opened a github issue. github.com/reactjs/react-transition-group/issues/625 – Laurence Fass May 09 '20 at 19:08

0 Answers0