-
-
Notifications
You must be signed in to change notification settings - Fork 455
Nextjs useForm gives a type error #470
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
Comments
This is a known issue caused by our bundler having issues. Note to self: figure out why TSUp isn't bundling deps properly. |
While certainly the error message is not ideal, does this actually cause any breaking issues? The hook seems to work as intended otherwise. 🤔 |
Can't run build command |
FWIW, It seems I can still build my project without error. But i still get this error when running dev: ⨯ node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]/node_modules/@tanstack/react-form/build/modern/useForm.js (29:2) @ useForm
⨯ TypeError: use_isomorphic_layout_effect__WEBPACK_IMPORTED_MODULE_1__ is not a function
at SettingsForm (settings/_components/SettingsForm.tsx:64:80) |
Cant build the project for both dev and prod environment. (Nextjs Pages Router)
Here are some logs for ya: Prod
Dev:
|
I've reproduced this locally and it might be an issue inside the use-isomorphic-layout-effect package:
So for some reason, NextJS gets the CJS version on the server instead of the ESM one, and it can't resolve the default export properly. I don't know if it's an issue with NextJS or the package itself but I've noticed that if I add the "exports": {
"require": {
"default": "./dist/use-isomorphic-layout-effect.cjs.js"
},
"import": {
"default": "./dist/use-isomorphic-layout-effect.esm.js"
}
} the issue disappears. That said, we probably don't need to use this package. Looking at the code here, all it does is: export default typeof document !== 'undefined' ? useLayoutEffect : useEffect; I've tried replacing the package with that code inside the |
@juliendelort this is good investigation. I will know however that I use this package simply because of React Native support. But admittedly that's changed since RN now supports import maps |
Ah yeah true, I forgot about react-native. I wonder if |
i have the exact same thoughts about it, as you mentioned it, all does is only a one line of code |
This fix made it into our Sorry for the headache y'all - I really don't know how I got it in my head that React Native wouldn't support this, seeing as I already knew it did from my time building HouseForm. |
Describe the bug
When i use
useForm
i get an error saying use_isomorphic_layout_effect_cjs is not a function. and it's due to Nextjs server side rendering.Right now I'm getting over it using Nextjs dynamic import and disabling ssr but it's not a good approach.
when i want to use
useForm
hook i get the bellow error:Your minimal, reproducible example
https://stackblitz.com/edit/stackblitz-starters-bbkdbd?file=components%2Fform.tsx
Steps to reproduce
Expected behavior
i expected that the useForm would work in a client component
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
Tanstack Form adapter
react-form
TanStack Form version
0.3.6
TypeScript version
5.2.2
Additional context
I just googled something and i found this: https://stackoverflow.com/questions/76609948/error-typeerror-0-useisomorphiclayouteffect-useisomorphiclayouteffect-is-n
The text was updated successfully, but these errors were encountered: