-
Notifications
You must be signed in to change notification settings - Fork 2
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 the trigger function #17
Conversation
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 will work but I just havent faced the usecase for it yet 🤔 , I will wait to check the usecase for it in ATS
It's rather simple, the 2 dates for interviews must be before/after the other one, so I need to revalidate both date on blur 😄 |
@send external triggerMultiple: (t, array<string>) => unit = "trigger" | ||
|
||
@send | ||
external triggerAndFocus: (t, string, @as(json`{ shouldFocus: true }`) _) => unit = "trigger" |
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.
why did we have to compile the string into the json here? Based on the provided example in the react hook form docs, this doesn't look to be json trigger('name', { shouldFocus: true })
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.
It's just the way to "inject" valid json value into js from rescript.
Also, keep in mind a json value is basically.... an object in js 😄
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.
looks good, thank you @gaku-sei.
I'm really curious to see the finished example on how the trigger will help in this case, for targetNumbers i used a more rudimentary approach to validate dates so that one is after the other. |
Implements https://react-hook-form.com/api/useform/trigger/
I used
@send external
instead of just adding it to the record to have more flexibility with no runtime costs. The API is a bit less consistent but more flexible. We could refactor records to use this technic too 😕