Jump to content
Search Community

React 18 with GSAP Problem

Tomasz Olek test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

  • Solution

Welcome to the forums, @Tomasz Olek


It looks like you just weren't doing proper cleanup. React 18 actually calls useEffect() TWICE in strict mode which catches a lot of people by surprise. It's quite unintuitive in my opinion. So due to that React behavior, you ended up creating multiple tweens/ScrollTriggers that were competing to control the same things simultaneously. 


The new gsap.context() is your new best friend in React. I'd strongly recommend reading this article: 

Here's a fork where all I changed was wrapping your code in a gsap.context() and then calling revert() on it in the cleanup function: 



Does that clear things up? 

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...