top | item 42806138

Validating React forms easily without third-party libraries

2 points| rcamargo | 1 year ago |rafaelcamargo.com

3 comments

order

rcamargo|1 year ago

Over the past few years, I've tried out a bunch of libraries that claimed to make React form validation easier. My takeaway? They're annoyingly intrusive and make the code way more complex than it needs to be. In this post, I'm sharing a library-free approach that is stupidly simple and has worked like a charm for my form validations. By writing just 2 functions, I avoid a whole library.

duxup|1 year ago

I found the same. They're so all encompassing that they're too complex to use.

I'm already working with React and it's behaviors, don't need something surprisingly large to learn for ... a form.

duxup|1 year ago

The more I code the less I validate on the front end (I do some) and the more I just let the form submit whatever because ... I have to check it on the back end again anyway.

As much as practical I'd rather let the back end do the validation and return some sensible message back to the user if there's a problem.

I think the example in the article is nice, that's not to say I disagree necessary with the article.