Jump to content
Search Community

colon character ":" in id throwing error

chacrasoftware test
Moderator Tag

Go to solution Solved by Rodrigo,

Recommended Posts

I have a component with dynamic id usinguseId()hook from react. it generates a string that contains a colon ":R1fakq:" something similar to this. then I will use this id to trigger a scrollTo with ScrollToPlugin but it throws an uncaught error. I tried manually setting the id with a colon character and it render the same issue. 

Link to comment
Share on other sites

  • Solution

Hi,

 

This is not a GSAP related issue, if you inspect the console you'll see that the error stems from the way the selector is being passed to the querySelectorAll() method GSAP uses under the hood.

 

Here you can find a couple of ways to get around this:

https://stackoverflow.com/questions/73894096/react-useid-creates-invalid-selector

 

Finally if I was you I'd drop that particular hook and find another way to add dynamic ids to my elements.

 

Hopefully this helps

Happy Tweening!

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