import { useTrail, animated } from 'react-spring'

Creates multiple springs with a single config, each spring will follow the previous one. Use it for staggered animations.

Either: overwrite values to change the animation

If you re-render the component with changed props, the animation will update.

const trail = useTrail(amount, { opacity: 1 })

Or: pass a function that returns values, and update using "set"

You will get an API object back. It will not cause the component to render like an overwrite would (the animation still executes of course). Handling updates like this is useful for fast-occurring updates, and you should generally prefer it as it's more powerful. Further documentation can be found in Imperatives & Refs

const [trail, api] = useTrail(amount, () => ({ opacity: 1 }))

// Update trail
api.start({ opacity: 0 })
// Stop trail

Finally: distribute animated props among the view

The return value is an array containing animated props.

return => <animated.div style={styles} />)


All properties of the shared-api apply.