Skip to content
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]: mutableImplStore.onSubmit is not a function #404

Open
2 of 5 tasks
cjoecker opened this issue Nov 29, 2024 · 2 comments
Open
2 of 5 tasks

[Bug]: mutableImplStore.onSubmit is not a function #404

cjoecker opened this issue Nov 29, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@cjoecker
Copy link

cjoecker commented Nov 29, 2024

Which packages are impacted?

  • @rvf/react
  • @rvf/remix
  • @rvf/zod
  • @rvf/yup
  • zod-form-data

What version of these packages are you using?

"@rvf/remix": "^6.3.0",

Please provide a link to a minimal reproduction of the issue.

https://stackblitz.com/edit/remix-run-remix-xdhnnj?file=app%2Froutes%2F_index.tsx

Steps to Reproduce the Bug or Issue

  1. Open stackblitz
  2. Submit the form and see that it doesn't work without throwing any error

Expected behavior

It throws a better error message than mutableImplStore.onSubmit is not a function in the onSubmitFailure function so I know I'm using the hook from react and not remix wrongly.

It will be nicer if the react hook detects when there is not a context and throws an error right away.

Screenshots or Videos

No response

Platform

Irrelevant

Additional context

I'm using Webstorm. As every developer that uses Intellij, I'm using the auto imports functionality. Because @rvf/react is always installed with RVF, it is likely that the useForm hook is not imported from @rvf/remix. Another error source is copying the example in the docs without paying attention to that. The issue is then difficult to find.

It would be nice to have also a section in the docs about debugging. I couldn't find easily the onSubmitFailure function. Without that, I couldn't find the error because the form was not submitting without any error.

@cjoecker cjoecker added the bug Something isn't working label Nov 29, 2024
@airjp73
Copy link
Owner

airjp73 commented Dec 11, 2024

I think a section in the docs on debugging makes a lot of sense!

Part of the problem here is that we allow handleSubmit to be omitted when submitSource: "dom", but then we're not actually supporting that case unless you specify reloadDocument: true. It's intended that this should perform a native form submission if you don't specify handleSubmit, so that's the fix we need to implement.

If we do that, now I'm wondering if reloadDocument even makes sense as an option in the core library. That could be an API that's only supported by the Remix adapter.

@cjoecker
Copy link
Author

From what you told me, reloadDocument doesn't make much sense in the core library. I would love to see some hints for debugging in the docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants