Follow me on Twitter, happy to take your suggestions on topics or improvements /Chris
50% if React developers DON'T use a form library, they bu...
For further actions, you may consider blocking this person and/or reporting abuse
Well, I think it's gonna take a long time before Hooks become a thing everyone uses and a lot of it.. I've dug some into Hooks as you can see from one of my other articles.. Also Hook is a new thinng and added to a late version of React so a lot of old React projects wont be able to use it until they upgrade. It's an interesting topic though.. I'm gonna look into it Forms + Hooks I mean :) Thanks for the comment
I definitely like the render props version over the higher-order component (HOC) version. I understand HOCs, but they always seem to hurt my brain.
I know Jared Palmer, creator of Formik, is working on a hooks implementation of Formik. Not sure if it's finished or in beta.
Ah cool, looking forward to the hooks version :)
Looks like the issue is still open.
Hooks Rewrite #1046
Looks like there's an alpha release for Formik with hooks now. 🎉
sweet :)
In the first example, you missed the 'name' property of the input, which might be confusing for others.
value={values.name}
type="text"
placeholder="Name">
thank you Mahmoud.. I've updated that throughout :)
There is an error on the validation snippet
validate={values => {
let errors = {};
if(!errors.name) {
errors.name = 'Name is required';
}
return errors;
}}
It's should be
!values.name
instead of!errors.name
of course it should.. thank you :)
This library is in an uncomfortable spot where it adds some functionality, but you'll still want to create more of a framework around it, tuned for the particular project.
For something like that, I'd always veer on the side of owning the entire feature code (by coding it myself or extracting code from the library's ), rather than having to hack around a black box that doesn't quite fit all my needs.