One of the main reasons I, and many others, love React is that it allows us to organize markup into reusable pieces.
Custom React hooks allow us t...
For further actions, you may consider blocking this person and/or reporting abuse
Thank you. Requires a second read but totally worth it
Glad you liked it!
Thank for this article! I've been working on a form component for some time and have been blindly adding complexity. And now that I'm trying to test and add more functionality it breaks down. Back to the basics, make it simple!
helpful
I have a question, why did you use the useReducer instead of create a useState like const [registerForm, setRegisterForm] = useState({...})?
Great question. You could create the form like you said:
but now the code to update the form needs to change. For example, to update the username, you'd have to write
and to update the password,
etc. You have to repeat the
(prevState) => ({ ...prevState,
part every time, which I'd rather not do. UsinguseReducer
allows me to define the update function once withand just pass the new state to
setRegisterForm
.ohhhh make sense, thanks for the reply !
Great article!
good job man <3
which lib do you use to generate PDFs?
The example was meant to be hypothetical, but I've heard jspdf is a good library.