You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 5, 2019. It is now read-only.
Proposed solution setTimeout(() => validate(), 0): perform validation at the next turn of event loop.
It would be nice to solve the out of sync issue inside the neoform package.
The text was updated successfully, but these errors were encountered:
It's hard to know from inside of NeoForm should we postpone validation till the next tick or not, what do you think about something like onChange(e.target.value, validate) as a special case workaround? The value flow is async because input is controlled, i.e. we have an onChange ↔︎ value loop using state.
Another option is to always and explicitly pass values like validate(value) in most cases and validate(e.target.value) in case of onChange.
@deepsweet
Thank you for the analysis. You are right, the next tick looks like a hack. In our opinion, the second option (to pass e.target.value in case of onChange) is more preferable. More over, the pending pull request #13 allows easily detect the event type change. Below is a possible implementation of this idea, based on #13:
Module fieldValidation.js. In method validate, along with name, pass an extra property value: event.target.value into form validation handler:
Module formValidation.js. In method validateField perfom validation, using passed event's value only in case of the change type. Otherwise, validate a value from the state:
It seems that validation and input aren't synchronized
See also this gist
Proposed solution
setTimeout(() => validate(), 0)
: perform validation at the next turn of event loop.It would be nice to solve the
out of sync issue
inside the neoform package.The text was updated successfully, but these errors were encountered: