useDynamicAnimation is a hook that lets you use style objects dynamically, rather than using static variants.
It has all the same performance benefits of
useAnimationState, with a more expressive API.
- High performance
- Zero re-renders
- Animations run on the native thread
- Easy API
Receives one (optional) argument: a pure function which returns the initial state. This is similar to React
useState's first argument.
Get the current animation state. Unlike
useState's return value, this can be safely read and accessed synchronously.
A function to animate to your next state. This is a worklet, so you can call it from the native thread.
You can also pass a function which receives the current style and returns the next state:
Any Moti styles are valid here. For example, if you want a sequence animation, just pass an array.