-
| Hi Thank you |
Beta Was this translation helpful? Give feedback.
Answered by hadikman Sep 26, 2024
Replies: 1 comment
-
| I came up with this solution with useSprings (it probably works with useSpring too): const SQUARES = Array.from({ length: 2 }, (_, i) => i) const squareRef = useSpringRef() const squareStyles = useSprings(4, SQUARES.map(id => ({ ref: squareRef, from: { ... }, to: { ... }, loop: true, // must be true })), ) React.useEffect(() => { if (isAnimate) { squareRef.start() } else { squareRef.start({ to: { ... }}) // important: the to object must be exactly the same as the to object in useSprings } }, [squareRef, isAnimate]) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by hadikman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
I came up with this solution with useSprings (it probably works with useSpring too):