this_is_giulio Posted January 17 Posted January 17 Hello everyone again, I have a React component with a `counter` state defined using `useState`. I use `useGSAP` to create a timeline with `scrollTrigger` and update the component’s state in the `onUpdate` callback. The problem is that the “old” `onUpdate` callbacks are not being cleared and continue to run. I created a repo to illustrate the issue quickly. https://stackblitz.com/edit/react-sfv36uzm?file=src%2FApp.js Where am I going wrong?
Rodrigo Posted January 20 Posted January 20 Hi, Sorry for the delay, this one slipped through the cracks 🙏 I think your approach might be a bit convoluted, this seems simpler and easier, plus you don't have to set the counter as a dependency and the setCounter method is not called on every update (pretty wasteful IMHO): https://stackblitz.com/edit/react-ckyyevug?file=src%2FApp.js Hopefully this helps Happy Twening!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now