Jump to content
Search Community

Gsap react target got undefined or not found

Sherlok test
Moderator Tag

Go to solution Solved by Rodrigo,

Recommended Posts

Hi,

 

I'm not in front of my computer now so there's not a lot I can do from my phone. 

 

What I can see is that you're not using the useLayoutEffect hook and you're not using GSAP context neither. I recommend you to check the resources in this page:

https://greensock.com/react

 

Also you can see some simple starter templates here where GSAP Context is being used

https://stackblitz.com/@GreenSockLearning/collections/gsap-react-starters

 

Finally you should update the versions of both react and GSAP, since the demo is using older ones. Give a try to the approach using GSAP context and the layout effect hook.

 

Most likely this stems from not using the layout effect hook and the DOM not being rendered when your GSAP code runs.

 

Hopefully this helps.

Happy Tweening!

Link to comment
Share on other sites

  • Solution

https://react.dev/reference/react/useLayoutEffect

 

This particular example shows how to use a GSAP timeline with a click handler

https://stackblitz.com/edit/gsap-react-basic-f48716

 

This is mostly react related. I recommend you to get a good look at the react page we have and that I linked before and perhaps learn your way around react and how to use event handlers and hooks.

https://greensock.com/react

 

Happy Tweening!

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