-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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] Cannot use react-hook-form Controller with Refine's useForm #6139
Comments
Hey @ritute, using a base Refine + Material UI + React Hook Form setup, I've followed the steps to repro the issue. Just copy-pasted the full Material UI code block and removed the |
Hmm, okay I just started with a base sandbox and don't see the issue either. Gonna try to figure out what's different then in my project's setup. |
@aliemir here's a reproduction The subscribe error only happens when use |
Hi @ritute, I found some syntax problems in your project and fixed them, but I didn't see the issue you're facing. However, I did find another error: ➜ Local: http://localhost:3000/
➜ Network: use --host to expose
➜ press h + enter to show help
✘ [ERROR] Could not resolve "@mui/material/DefaultPropsProvider"
node_modules/@mui/lab/LoadingButton/LoadingButton.js:12:32:
12 │ import { useDefaultProps } from '@mui/material/DefaultPropsProvider';
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can mark the path "@mui/material/DefaultPropsProvider" as external to exclude it from the
bundle, which will remove this error and leave the unresolved path in the bundle.
/Users/alicanerdurmaz/Desktop/refine-form-demo/node_modules/esbuild/lib/main.js:1651
let error = new Error(text);
^
Error: Build failed with 1 error:
node_modules/@mui/lab/LoadingButton/LoadingButton.js:12:32: ERROR: Could not resolve "@mui/material/DefaultPropsProvider"
at failureErrorWithLog (/Users/alicanerdurmaz/Desktop/refine-form-demo/node_modules/esbuild/lib/main.js:1651:15)
at /Users/alicanerdurmaz/Desktop/refine-form-demo/node_modules/esbuild/lib/main.js:1059:25
at /Users/alicanerdurmaz/Desktop/refine-form-demo/node_modules/esbuild/lib/main.js:1527:9
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
errors: [Getter/Setter],
warnings: [Getter/Setter]
}
Node.js v20.11.0 This error was resolved when I updated Could you please recheck the project you shared? I couldn't reproduce the error you got. |
@alicanerdurmaz @aliemir fixed the syntax error for the commented Edit wrapper, my bad. I don't get that MUI error. Can you make sure you're using the yarn lock file that's there with |
Hey @ritute thank you for the update. I cloned the repo and used yarn v1 to install. Now I can reproduce the same issue 🙌 I'll try to investigate on what caused the issue but when I replace the Can you check if updating the dependency also works for you? Do you have any limitations to keep the |
@aliemir I noticed that the Refine library was using this version 7.30.0 for |
@aliemir it worked with version 7.52.1 (but needed to add it to resolutions since Refine is using 7.30.0) |
The version bump of I found the issue in the Happy to see the issue is resolved after the update. Since we've found the exact version that resolves the issue, I think we can mark our |
If anyone is interested on working on the fix, it should be as simple as replacing all |
Okay sure I can do that. But hmm something doesn’t make sense as when I
used the older version of react-hook-form I didn’t run into this runtime
error when using the useForm from their package vs Refine’s. You can try
that repo and just instead of using Refine’s useForm, use the one from
react-hook-form.
…On Fri, Jul 19, 2024 at 2:46 AM Ali Emir Şen ***@***.***> wrote:
If anyone is interested on working on the fix, it should be as simple as
replacing all "react-hook-form": "^7.30.0" with "react-hook-form":
"^7.43.5" in the repo. @ritute <https://github.com/ritute> I can assign
this to you if you can work on it. We'll be happy to see your PR 🙏
—
Reply to this email directly, view it on GitHub
<#6139 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFVZ45UXJLHS4JKOJENBJDZNCY5TAVCNFSM6AAAAABK3OY3Y6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZYGQ3DENJTGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@aliemir is there any reason you guys don't expose |
@ritute, For the previous question, check out the source code for the https://github.com/refinedev/refine/blob/master/packages/react-hook-form/src/useForm/index.ts We're not just using or re-implementing the I hope I clarified the difference and the reason behind two packages and two hooks ✌️ |
@aliemir getting this when running |
@ritute I checked but couldn't find the same version code. Can you check |
@aliemir ah, oh my, I somehow added that... 😂. All good! BTW, there are several tests that fail in master for me - looks like a timezone related issue. |
Describe the bug
I'm following the example for Material UI on this page: https://refine.dev/docs/packages/react-hook-form/introduction/#usage
My imports are:
The problem is that it looks we have to use the Edit component from Material UI in order to use Controller, otherwise I get the error:
React Router caught the following error during render TypeError: Cannot read properties of undefined (reading 'subscribe')
When I wrap my form within the Edit component, this error goes away, but I don't want to use Edit from material UI for my form. Is there a way around this? I'm currently having to use register instead, but I need to use some Material components like Autocomplete.
Steps To Reproduce
Expected behavior
Shouldn't require the Edit component in order to use Controller in my form.
Packages
Additional Context
No response
The text was updated successfully, but these errors were encountered: