Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. import React from "react";
  2. import { Route, withRouter } from "react-router-dom";
  3. import { AnimatedSwitch } from "./AnimatedSwitch";
  4.  
  5. /**
  6. * The ".page" class is key to animating a full page and not receive bumps while
  7. * animating pages in/out. It is position: fixed to allow the animation to play
  8. * without the DOM elements messing up.
  9. *
  10. * Try to remove .page to see the effect.
  11. */
  12. const PageOne = () => (
  13. <div className="page pink">
  14. <h1>Hello PageOne</h1>
  15. </div>
  16. );
  17. const PageTwo = () => (
  18. <div className="page green">
  19. <h1>Hello PageTwo</h1>
  20. </div>
  21. );
  22.  
  23.  
  24. const routes = [
  25. {
  26. component: PageOne,
  27. path: "/"
  28. },
  29. {
  30. component: PageTwo,
  31. path: "/two"
  32. }
  33. ];
  34.  
  35. const Routes = withRouter(({ location }) => {
  36. return (
  37. <AnimatedSwitch location={location}>
  38. {routes.map(route => {
  39. return (
  40. <Route
  41. exact
  42. key={route.path}
  43. path={route.path}
  44. component={route.component}
  45. />
  46. );
  47. })}
  48. </AnimatedSwitch>
  49. );
  50. });
  51.  
  52. export default Routes;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement