-
-
Notifications
You must be signed in to change notification settings - Fork 436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Compatibility with React v19 #602
Comments
@CHE1RON I was trying to replicate the problem but I was unable to. Can you confirm it is not caused by https://react.dev/blog/2024/04/25/react-19-upgrade-guide#ref-cleanup-required ? |
thanks for letting me know, I'll confirm that and get back to you! |
Same problem here. Had to cast :( const containerElementRef = useRef<HTMLDivElement>(null)
const isHovering = useHover(containerElementRef as RefObject<HTMLDivElement>)
// ^ 😭 |
Yeah, me too, casting always feels like you were given typesafety candy and then having to give it back .. |
I'd sooner annotate with const containerElementRef = useRef<HTMLDivElement>(null)
// @ts-expect-error React 19 type compatibility, nullable ref can be ignored.
const isHovering = useHover(containerElementRef) |
encountered the same problem with |
Same happens for |
I’m closing this issue as usehooks now supports React 19. Feel free to reopen it if any issues persist or new ones arise. |
The nullable ref type problem is not the same thing as React 19 compatibility (#650), although it is specific to React 19. The issue persists with the latest version of the package, and you have to work around it by casting or ignoring the error, as outined above. |
Yeah, sorry @juliencrn. Could you re-open this? This is one that is going to have to be resolved with a major version bump. |
Describe the bug
Currently, when using React v19 (currently RC), it gives an error regarding
ref
objects being passed to hooks, see here:To Reproduce
Simply follow the upgrade guide and install React v19 RC, then try to build the project using
usehooks-ts
.Expected behavior
build
step succeedsAdditional context
No response
The text was updated successfully, but these errors were encountered: