-
Notifications
You must be signed in to change notification settings - Fork 0
Conversation
509d3c6
to
6d20987
Compare
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.
Worried about our own useField and final-form useField conflict in DX
Wouldn't useOnFieldChange be able to handle this kind of issue ?
What are we trying to implement here ? :)
Yeah, that may be concerning, but we do the same with
From what I understand, The whole point of this PR is to update input metadata when the validation props are changing. |
6d20987
to
cd93b16
Compare
@DorianMaliszewski suggested renaming the custom We also discussed other potential solutions. This is the best one we could find. |
cd93b16
to
ea6e1b7
Compare
🎉 This PR is included in version 1.32.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
Enable dynamic validation. For example, if we need a field to change its required prop based on other fields value.
I created a
useField
wrapper that changes itsdata
property (to trigger a field reload) if thevalidate
function has changed. We have to do this ourselves because theuseField
hook fromreact-final-form
doesn't "reload" the field if the validate function changes (See this comment in the source code)Also, now this new
useField
hook is callingpickValidators
anduseValidation
itself. It results in a cleaner code IMO 👌Relevant logs and/or screenshots
Before
CleanShot.2022-09-27.at.13.28.55.mp4
After
CleanShot.2022-09-27.at.13.29.23.mp4