2020-05-18
1497
#react
Kristofer Selbekk
18674
May 18, 2020 ⋅ 5 min read

Creating forms in React in 2020

Kristofer Selbekk Bekker. Bulldog owner. Dad. React enthusiast. 🎩🥂🍔

Recent posts:

Rxjs Adoption Guide: Overview, Examples, And Alternatives

RxJS adoption guide: Overview, examples, and alternatives

Get to know RxJS features, benefits, and more to help you understand what it is, how it works, and why you should use it.

Emmanuel Odioko
Jul 26, 2024 ⋅ 13 min read
Decoupling Monoliths Into Microservices With Feature Flags

Decoupling monoliths into microservices with feature flags

Explore how to effectively break down a monolithic application into microservices using feature flags and Flagsmith.

Kayode Adeniyi
Jul 25, 2024 ⋅ 10 min read
Lots of multi-colored blue and purplish rectangles.

Animating dialog and popover elements with CSS @starting-style

Native dialog and popover elements have their own well-defined roles in modern-day frontend web development. Dialog elements are known to […]

Rahul Chhodde
Jul 24, 2024 ⋅ 10 min read
Using Llama Index To Add Personal Data To Large Language Models

Using LlamaIndex to add personal data to LLMs

LlamaIndex provides tools for ingesting, processing, and implementing complex query workflows that combine data access with LLM prompting.

Ukeje Goodness
Jul 23, 2024 ⋅ 5 min read
View all posts

13 Replies to "Creating forms in React in 2020"

  1. Nice post, wish when I read all these forms in react blogs though that they’d include nice ways the include validation

  2. Great article 👍
    There is a small typo in the first example. You entered username.. probably ment email

  3. I think, the approach you used for get data using FormData, it’s antipattern in react. Please see controlled components vs uncontrolled components.

  4. I think what the author is trying to say throughout the article is that in simple cases, the overhead of controlled components doesn’t bring any additional benefits. Just using uncontrolled components alone isn’t an anti pattern.

  5. Hi ,
    I use a custom hook, but the problem is that I also have a large list in the component. When I do the onChange operation, this list becomes re render again and greatly reduces performance.

  6. Your code works fine until a checkbox is added. The formData doesn’t seem to return a true/false value.

    const formData = new FormData(e.target as HTMLFormElement);

    The formData.get(‘registerMe’) returns ‘on’ instead of true/false. I cannot think of any other way except to access the checkbox value directly:

    e.target.elements[‘registerMe’].checked

    So wouldn’t it be better to access the elements directly rather than through the FormData? You already have a reference to the form and can access the values.

Leave a Reply