-
Notifications
You must be signed in to change notification settings - Fork 4
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
Advanced: Form state management step 2 – useLoginForm #11
base: lessons/08-react-apis
Are you sure you want to change the base?
Advanced: Form state management step 2 – useLoginForm #11
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
setTouched((touched) => ({ ...touched, [name]: true })) | ||
}, []) | ||
|
||
return { |
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.
Not gonna pretend I understand all the type syntax used, but it's nice to what potentially Formik or ReactHooks are doing under the hood.
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.
Completely agree. Until this point I was pretty confident whats going on in our project, but this one seems more like an expert approach. Nice showcase.
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.
@OndrejDrapalik @matyasmihalka this definitely isn't the most straight-forward code. In fact, this is why we decided it wasn't necessary to include as our "main track" in the application.
The idea here is really to showcase how libraries such as Formik are made, and how complex proper form state handling can be without those libraries.
I'll give you a hint though: React Hook Forms is way, waaay more complex than Formik, as it takes over React entirely, building it's solution on top of traps and Proxy states, executing hooks dynamically based on state consumption. Quite neat. If you are interested, we could have a chat about it or explore a simpler isolated solution to showcase the technique.
28f7794
to
1acb7d4
Compare
The changes contained in this PR are considered advanced, and won't be part of the final application. We'll leave it here as a reference and for learning purposes.
With the introduction of login form state management after Lesson 08: Built in React APIs, we've learned how hard it can become to handle form state manually – input values, validation states, errors, submit state, etc. And, if we manage to have the state itself working, chances are the UX won't be the best anyway. That's probably enough for us to realize how form libraries are essential to building high-quality forms in our applications.
But, what about we push a little bit more, and pretend there was no form library at our disposal? Turns out this is a great opportunity for us to play around with React APIs.
This PR builds on top of the the previous login form state managing to cover: