Closed studiosi closed 3 months ago
Hm, it's very difficult to troubleshoot blind, but it kinda sounds like you don't have React installed or something. The useRef is being imported at the top from "react"...and the error indicates that's null. There must be some issue with your environment(?)
Maybe try spinning up the simplest possible React project and do a basic useGSAP() in that and see if it works. If you can recreate the problem there, send us the repo or something so we can have some way of seeing the problem in context. It certainly sounds like a problem in your environment or build tool or something.
We saw this when attempting to run on react@rc (v19).
same issue with react 19 beta, react, vite
@jackdoyle I have to say that yes, I have React installed (it is a working NextJS installation), I had already GSAP working (doing all the work manually) and that this is a type error.
Thanks for checking it out. I will try to create a minimal reproduction as soon as I can.
I am closing this because I can't seem to be able to reproduce the issue. In case someone wants to check a minimal example of using GSAP inside of a Typescript Next.js app with TailwindCSS, I created this example while I was trying to make this error happen.
For anyone who had the issue with react RC19...
You can add this to your package.json file to force the gsap plugin to reference the correct version of react.
"overrides": { "@gsap/react": { "react": YOUR_REACT_RC_VERSION } }
hope this helps :-)
Getting the same issue. @seismicsix could you give more details about
"overrides": { "@gsap/react": { "react": YOUR_REACT_RC_VERSION } } ?
I've tried
"overrides": {
"@gsap/react": {
"react": "18.2.0"
}
}
but no luck, thanks in advance
Getting the same issue. @seismicsix could you give more details about
"overrides": { "@gsap/react": { "react": YOUR_REACT_RC_VERSION } } ?
I've tried
"overrides": { "@gsap/react": { "react": "18.2.0" } }
but no luck, thanks in advance
YOUR_REACT_RC_VERSION = should reference the react version 19 you're trying to install; so update;
"react": "18.2.0"
to something like
"react": "19.0.0-rc-??????-????"
Hello,
I am just on a normal installation of NextJS in which I have been using GSAP for a while.
When trying to use useGSAP for automatic cleanup, I get this error
TypeError: Cannot read properties of null (reading 'useRef')
which is generated on this line
https://github.com/greensock/react/blob/b00905d1e00ce0b873e6c4b0cb09770254836b55/src/index.js#L32
I wonder if this is a problem with the usage of
useRef
or something that I am doing wrong.