Skip to content

Instantly share code, notes, and snippets.

@mhaagens
Last active July 8, 2017 18:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhaagens/93d62b9fa812e7c898e55a2a5f8a3569 to your computer and use it in GitHub Desktop.
Save mhaagens/93d62b9fa812e7c898e55a2a5f8a3569 to your computer and use it in GitHub Desktop.
AnimatedRoute Wrapper
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;
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