-
Notifications
You must be signed in to change notification settings - Fork 26.4k
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
Next 13: experimental appDir breaks react-hook-form useForm() #42263
Comments
I don't recall if the pages directory uses server components by default like the app directory does but if so I believe that can be an issue and you have to add 'use client' At the top. Try console logging in your component to identify if it's a server or client component. |
Sorry, I forgot to mention that I've tried both with and without 'use cllient' at the top and I get the same error. I'm pretty sure it shouldn't matter though as long as nothing within the app directory is importing it. |
If your reproduction matches exactly your setup, you need to add |
Hi @lukemorales thanks for the work around. Do you know now the reason of why this happens? |
I'm also seeing a similiar issue using pages dir with standalone builds. For me removing standalone builds seems to resolve the issue. However, this increases our image sizes so isn't optimal. I get this error |
Verify canary release
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:23 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T6000
Binaries:
Node: 16.17.0
npm: 5.1.0
Yarn: 1.22.19
pnpm: N/A
Relevant packages:
next: 13.0.1-canary.3
eslint-config-next: 13.0.0
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
I have been using
react-hook-form
and after upgrading to Next 13 I am setting the following error related to theiruseForm()
hook. I am not using the new app directory, but when I setexperimental: { appDir: true }
in my next config I get the following error:I opened this issue here first because it seems directly related to the app directory config and wanted to get a better understanding as to what might be affected this before opening an issue with them.
Expected Behavior
App works perfectly fine without the invalid hook warning and type error when
appDiir
is set to false. Since none of the apps components live within the newapp
directory we would expect the behavior to be the same even whenappDir
is enabled.Link to reproduction
https://stackblitz.com/edit/vercel-next-js-aufyu7?file=next.config.js
To Reproduce
Run
next dev
and try to refresh the page and you will see the error.The text was updated successfully, but these errors were encountered: