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
General - Research libraries for redesigning our form architecture #45
Comments
A few blogs I've read comparing Formik and React Hook Forms make it seem that React Hook Forms is the better option because it is more performant and has a smaller package size. However, the two are fairly similar, so it may come to deciding which seems easiest for us to implement. Sources: |
This is awesome! I want your opinion: which package do you think is more intuitive? Which do you think will provide the functionality we will later need? I personally don't care a lot about bundle size. As long as we're avoiding bloated packages, we generally should be fine. Bundle size reduction can be handled later down the line. Usually differences in bundle size are negligible, especially at this stage of our application. Things I do care about:
Forms things I would consider:
|
As far as validation goes, I was thinking of utilizing yup. I've seen examples of yup being integrated into both React Hook Forms and Formik, so with either option, I think we should consider yup to standardize and abstract away our form validation. I'll keep looking through React Hook Forms, but from what I've seen so far, React Hook Forms is fairly easy to use as it doesn't require us to use new components and there are a lot of usage examples we can reference from. Not sure how well it fits our mutate async pattern yet though, so I'll have to look into that more but right now I'm leaning towards using React Hook Forms. |
I think before we create an epic for integrating any of these packages though, we should have one test ticket to try implementing the new package for conforming our current forms to the new package to see how feasible it is. I wouldn't mind taking that up if we get to that point. |
Here are my findings for React Hook Forms so far:
|
Here are my findings for Formik so far:
Note: Formik has its own set of components for creating forms (you could use the hook version of Formik to eliminate the need to learn new components but there would be a lot of boilerplate code) that developers would need to learn, it doesn't look too complicated to understand, but it will take time. This is one of the major differences between React Hook Forms and Formik, and one of the reasons I'm currently leaning towards React Hook Forms. |
My current standing on this is that we go with React Hook Forms and do a trial run by converting one of our forms to use React Hook Forms (with all the built out validation using yup and other necessary validating helper functions) to see how it feels and if it looks somewhat straightforward for other devs to convert our forms to use React Hook Forms. My main points for React Hook Forms are that devs don't need to learn how to use new components, just how to integrate React Hook Forms to be used in our current components (which with an example form shouldn't be too difficult) and that it seems to be used in other actual products as well (here I'm purely going off the fact that my co-op uses React Hook Forms over Formik) so it would be good to learn now before going on co-op. In both cases though, we would use yup to do schema validation on the form and then have separate validation (probably within the API calls/services we have that do our API calls to ensure our form inputs are actually valid and map to existing records in our database) and can continue with our NOTE: the integration for React Hook Forms with react-bootstrap isn't as easy to find/straightforward as Formik is, but I can look into finding those resources so devs can easily figure that out. It seems React Hook Forms is more set up to interact with MUI rather than React Bootstrap, but I think it may be possible to do the registering of the form inputs in the same way as with normal HTML elements since React Bootstrap components should just be HOC's or wrapper component of the normal HTML elements. |
This is amazing to see! Yes let’s definitely spin up a ticket for doing a trial run migration of a form to this new package. I want to say that this can also be a chance for us to trial having a feature branch for integrating this new package. The one thing I’m still wondering is why |
From my understanding, |
Thank you Justin! That clarifies it a ton! If you feel as though |
Note to self: Make a ticket to test converting one of our forms to use React Hook Forms |
Note to self: close this issue only after a successful trial is done for converting one of our forms to whichever forms library we end up using. |
it works so this ticket is done |
Desired Changes
As of now, we currently use states and pass those down to the view components to get the data from our forms and then send them back up to our container component to do business logic with them/pass the data to our custom react hooks. We also manually do form validation, and our current validation is the bare minimum at best. We want to utilize existing libraries that provide the tools and architecture that would allow us to create flexible forms with proper validation and are easy to build. Some potential options we have right now are Formik and React Hook Forms.
Screenshots (as needed)
No response
The text was updated successfully, but these errors were encountered: