-
Notifications
You must be signed in to change notification settings - Fork 35
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
Add target and change update handlers api #72
Conversation
/> | ||
``` | ||
|
||
The value of the field is exposed via `form.input` record. For extra safety, we disable all inputs during form submission using `form.submitting` property which is of boolean type. The next 2 functions are very important: | ||
1. `form.blurEmail: unit => unit`: must be triggered from `onBlur` handler of an input field | ||
2. `form.updateEmail: (input => input) => unit`: must be triggered from `onChange` handler of an input field. It takes a function as an argument which takes the current form `input` and must return updated `input` record. | ||
1. `form.blurEmail: ReactEvent.Focus.t => unit`: must be triggered from `onBlur` handler of an input field |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type signature is much better! The intended use is encoded in the function type sig instead of a unit => unit
``` | ||
|
||
This runtime error happens due to [React's `SyntheticEvent` being pooled](https://reactjs.org/docs/events.html#event-pooling). Since callback gets triggered asynchronously, by the time it gets called, the event is already null'ed by React. | ||
1. `form.blurEmail: unit => unit` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% sure on what we'd get back for a blur event in React Native. CC @endlo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering that in react native api there are event-less handlers exist, we shouldn't encode events in formality handlers b/c it would restrict usage only to RN handlers with events which is unnecessary limitation imo.
If @endlo doesn't have anything to add then this looks gtg to me |
Published |
Fixes #68
/cc @johnhaley81