Skip to content

Commit

Permalink
Update animated-routes example to animate properly. See react spring …
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-cusan authored and tannerlinsley committed Jan 4, 2019
1 parent b042e9d commit 67e6d0e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions docs/guides/animated-routes.md
Expand Up @@ -9,7 +9,7 @@ Animated Routes can be achieved so many different ways. In this example, we'll s
import React from 'react'
import { Root, Routes } from 'react-static'
import { Link } from '@reach/router'
import { Transition } from 'react-spring'
import { Transition, animated } from 'react-spring'

const App = () => (
<Root>
Expand All @@ -22,17 +22,22 @@ const App = () => (
<Routes>
{({ routePath, getComponentForPath }) => {
// Using the routePath as the key, both routes will render at the same time for the transition
const Comp = getComponentForPath(routePath)
// Get the
return (
<Transition
native
keys={routePath}
items={routePath}
from={{ transform: 'translateY(100px)', opacity: 0 }}
enter={{ transform: 'translateY(0px)', opacity: 1 }}
leave={{ transform: 'translateY(100px)', opacity: 0 }}
>
{style => <Comp style={style} />}
{item => props => {
const Comp = getComponentForPath(item)
return (
<animated.div style={props}>
<Comp />
</animated.div>
)
}}
</Transition>
)
}}
Expand Down

0 comments on commit 67e6d0e

Please sign in to comment.