Last active
July 8, 2017 18:10
-
-
Save mhaagens/93d62b9fa812e7c898e55a2a5f8a3569 to your computer and use it in GitHub Desktop.
AnimatedRoute Wrapper
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 React from "react"; | |
import { Route } from "react-router-dom"; | |
import TransitionGroup from "react-transition-group/TransitionGroup"; | |
import { firstChild } from "../../utils/helpers"; | |
const AnimatedRoute = ({ component: Component, exact, path }) => ( | |
<Route | |
exact={exact} | |
path={path} | |
render={({ match, ...rest }) => ( | |
<TransitionGroup component={firstChild}> | |
{match && <Component {...rest} />} | |
</TransitionGroup> | |
)}/> | |
); | |
export default AnimatedRoute; |
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 React, { Component } from "react"; | |
import AnimatedRoute from "./hoc/animated_route"; | |
import Dashboard from "./dashboard"; | |
export default class App extends Component { | |
render() { | |
return ( | |
<div className="wrapper"> | |
<AnimatedRoute exact path="/" component={Dashboard} /> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment