refactor(explorer): move faucet form from formik to react-hook-form #846
+87
−67
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This replaces formik in the explorer faucet fund form. This doesn't remove the
formik
dependency, yet, because we still have these files using formik:I have one concern that I really haven't found the right solution for. I think a blue sky implementation of react-hook-form looks something like this:
In theory, this should extend react-hook-form's
FieldValues
to be properly typed and, for example, prevent trying to register a property that doesn't exist in the type or use a value of the wrong type. The problem? I can't figure out how to receive that type in the ReactHookForm component. I've tried pretty much everything I can think of, including aT Extends FieldValues
approach, but it hasn't worked. In lieu of that panning out, this implementation does work-setting the type in the data of theonSubmit
. But you won't be properly checked around registering and setting values the way you might be if we could receive the type correctly in the ReactHookFormField component'sFieldValues
. Open to ideas here, for sure.Otherwise, this does remove
formik
forreact-hook-form
in the faucet form. There just may be a better way to type it on the component side which would somewhat affect this implementation.