Thanks for sharing, cool article. Especially the new FormData(e.target) part make things more easy.
My opinion: don't use "controlled components". If you have them, remove them and use the approach <form onSubmit={..}>. If you need validation, you can check input in onChange and use like setUsernameError(..) if you need to really render the component to show an error, but not every keyboard hit will make it render.
At least there are some libs for forms.
Yes, you're right, and I personally use the same approach too, but I have seen in codebases, sometimes people like to use this value{ x } onChange={e => setX(e.target.value)}
Thought might include it as well!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for sharing, cool article. Especially the
new FormData(e.target)
part make things more easy.My opinion: don't use "controlled components". If you have them, remove them and use the approach
<form onSubmit={..}>
. If you need validation, you can check input inonChange
and use likesetUsernameError(..)
if you need to really render the component to show an error, but not every keyboard hit will make it render.At least there are some libs for forms.
Thanks for the comment, Philipp :)
Yes, you're right, and I personally use the same approach too, but I have seen in codebases, sometimes people like to use this
value{ x } onChange={e => setX(e.target.value)}
Thought might include it as well!