Jump to content
Search Community

Animation works and then disappears automatically

KidNinja
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Posted

I have this simple text animation. I was following a tutorial on youtube. The animation works as expected but after it is completed it seems to automatically hide itself. I have included a video below.

  • Solution
Posted

Welcome to the forums, @KidNinja

 

It looks like you just aren't doing proper cleanup. In React 18, useEffect() is actually called TWICE. So you're inadvertently creating duplicate/competing animations. That's why gsap.context() is your new best friend in React - please read this article: 

 

It makes cleanup super easy.

 

Is this what you were looking for?: 

https://codesandbox.io/s/silent-surf-gm3896?file=/src/App.js

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...