Validations run on unmount creating unnecessary requests
See original GitHub issueAre you submitting a bug report or a feature request?
Bug
What is the current behavior?
When leaving a form that is embedded in a dialog, the form is unmounted which in turn calls unsubscribe and ultimately that runs field validations. In the case a user cancels on a complex form with server side validations, it creates a noticeable slowdown of ui as well as unnecessary requests to the server.
What is the expected behavior?
Unmount will avoid unnecessary work.
Sandbox Link
Reproduction based on the Synchronous field-level validation
https://codesandbox.io/s/pw19j1x52m
- allow to render initially
- clear console
- click
Unmount form
- observe validations firing by added console logs
What’s your environment?
Sandbox updated to latest. ff: 4.11.0 rff: 4.0.2
Other information
possibly related #336
Issue Analytics
- State:
- Created 5 years ago
- Reactions:10
- Comments:6 (4 by maintainers)
Top Results From Across the Web
c# - Disable Required validation attribute under certain ...
You can remove all validation off a property with the following in your controller ... Create an attribute and mark your action method...
Read more >Model validation in ASP.NET Core MVC | Microsoft Learn
Client-side validation prevents submission until the form is valid. The Submit button runs JavaScript that either submits the form or displays ...
Read more >Form and field validation - Django documentation
A validator is a callable object or function that takes a value and returns nothing if the value is valid or raises a...
Read more >Rails Validation: Pitfalls in Validating Uniqueness with Active ...
Rails provides an easy way to validate records for uniqueness, but relying solely on Rails validation could be quite troublesome.
Read more >How to remove boilerplate validation logic in your REST APIs ...
Request validators also support basic validation of required HTTP ... To create the demo API, run the following commands (requires the AWS ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I also ran into this bug, since we do cryptographic options to validate a form, when a form is unmounted (even post-submission), the unregistrations cause validation to run once for every field that was unmounted (including
useField
hooks that are only subscribing to state).My solution is:
which should be placed as the first component within a
Form
’s children.Published fix in
v6.3.1
.