"Invalid Hook Call" with React code in third-party package, same code in Repo works
I have created a minimal reproduction here:
https://github.com/phryneas/reproduction-vite-invalid-hook-call-from-package
Essentially, once I declare a component
in an external package,
vite dev crashes out on me with
Invalid hook call. Hooks can only be called inside of the body of a function component.But once I inline that code in the respository instead of calling it from a third party package, everything works. That said, there is definitely only one version of React installed, and said package (has a peer dependency on React). I believe this might be a vite bug at this point - or a weirdness with the TanStack Start vite plugin. It's hard for me to pinpoint. Could someone take a look?
1 Reply
sensitive-blueOP•3mo ago
(Seems this is a TanStack vite plugin thing, so I'm closing this here)