Intro:
I'm trying to reset animation after some user activities(such as "clicking on close button", etc).
Code:
const animation = useSpring({
from: {
scale: 1
},
to: {
scale: 1.15
},
config: {
duration: 1000
},
loop: true
})
const onClickHandler = () => {
animation.reset() // Property 'reset' does not exist on type '{ scale: SpringValue<number>; }'
}
Problem:
Property 'reset' does not exist on type '{ scale: SpringValue; }'
1/ I've tried to check reset
method. Documentation said it's done, but it's not. https://react-spring.dev/docs/advanced/spring-value#reset
2/ I've tried to use this example, but it's not working in my case. The animation is not resetting to default state.
Question:
How can I reset useSpring
(and useTransition
) animation?
Context:
- "@react-spring/web": "^9.6.1"