Share Posted July 12, 2022 In the below link, the GSAP effect is working on page load. However, when I refresh the page, it no longer works. Why is this? I tried using a useEffect hook but that didn't work. https://codesandbox.io/s/wonderful-elbakyan-enusid?file=/src/App.js Link to comment Share on other sites More sharing options...
Solution Solution Share Posted July 12, 2022 I assume you wanted something like this?: https://codesandbox.io/s/modest-haslett-fvkipm?file=/src/App.js I'm not much of a React guy, but I believe it requires you to useEffect() otherwise your code will run again and again every time the component renders, and you must define an empty dependency array. Also, you can't use "class" in your jsx - I think it has to be "className". Again, a React thing. Totally unrelated to GSAP. You might want to read I hope that helps. 1 Link to comment Share on other sites More sharing options...
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