Animation Control
useAnimate
Create imperative animations with a scoped selector:useAnimationControls
Create animation controls to manually trigger animations:useAnimation (deprecated but still available)
Motion Values
useMotionValue
Create a motion value that can be used in animations without triggering re-renders:- No re-renders when value changes
- Subscribable
- Can be passed to multiple components
useTransform
Transform one motion value into another:useSpring
Create a motion value that animates to its target with spring physics:useScroll
Track scroll position and progress:scrollX/scrollY- Absolute scroll position in pixelsscrollXProgress/scrollYProgress- Scroll progress from 0 to 1
useMotionTemplate
Combine motion values into a template string:useVelocity
Track the velocity of a motion value:Viewport Detection
useInView
Detect when an element enters the viewport:Presence
usePresence
Check if component is present within AnimatePresence:useIsPresent
Simpler version that only returns presence state:Utility Hooks
useCycle
Cycle through a series of values:useReducedMotion
Respect user’s reduced motion preference:useAnimationFrame
Run a callback on every animation frame:useTime
Get elapsed time since component mount:useDragControls
Manually control drag gestures:start(event, options)- Start draggingcancel()- Cancel dragstop()- Stop drag
Advanced Hooks
useAnimatedState
Note: This is not officially supported and may be removed. Animate arbitrary state objects:Combining Hooks
Hooks can be combined for powerful effects:Best Practices
- Use
useMotionValuefor high-frequency updates - Avoids re-renders - Memoize callbacks - Especially with
useAnimationFrame - Clean up subscriptions - Motion values should be unsubscribed
- Use hooks at top level - Follow React’s rules of hooks
- Prefer declarative animations - Use hooks for imperative control when needed