forge42dev / remix-hook-form

Open source wrapper for react-hook-form aimed at Remix.run
MIT License
330 stars 27 forks source link

Multiple forms on a single page #94

Closed jkehler closed 2 months ago

jkehler commented 4 months ago

I'm using multiple forms on an account settings page. Eg one for updating user details, and another form for changing the password.

So I'm defining 2 useRemixForm variables for each form. This all works fine. However, I'm using the form.formState.isSubmitting to show a loader. I noticed that both of my forms loading state is being triggered even though I'm only submitting one of them.

jkehler commented 4 months ago

I was able to work around the issue by passing a fetcher instead and then adding checks on the fetcher formData to determine which action is being triggered.

AlemTuzlak commented 2 months ago

@jkehler that would be the best way to solve the issue, the isSubmitting function checks if the navigation.state !== "idle" which is true for both forms, fetchers obviously allow you to be more flexible here. They would have their own submission states and allow for checking this!