seasonedcc / remix-forms

The full-stack form library for Remix and React Router
https://remix-forms.seasoned.cc
MIT License
492 stars 25 forks source link

form with mode="onChange" button flashes when it hydrates #224

Closed deanfields closed 1 year ago

deanfields commented 1 year ago

When the page is loaded, the button is active, once the validation kicks in the button is disabled. Is there a way to make the button disabled on page load so it doesn't flash when it hydrates and validates the schema client side?

danielweinmann commented 1 year ago

Hey, @deanfields! Sorry for the delay. We do this for progressive enhancement reasons: while there's no JS available, the user should be able to submit the form and get feedback from the server-side validations.

But if that's not a concern for you, you can make your buttonComponent derive it's disabled prop from the form state through useFormState and make it default to disabled.

danielweinmann commented 1 year ago

I'm closing the issue but feel free to reopen it at any time.