Form & Function
An online publication brought to you by the team at Formspree featuring editorial writing and technical how-tos on static site generation, HTML forms, and other web technologies you can use to get your site well built and running fast on the Internet.
In Part 1 we talked about building a simple contact form using an uncontrolled component. In an uncontrolled component, validation is left up to the browser. As we discussed, this can lead to an inconsistent experience across browsers.
In this tutorial we’ll modify our basic form by taking control of the form’s state. In doing this we’ll create what React calls a “controlled component.” With a controlled component we’ll have more control over the form, allowing us to create a consistent validation experience, and customize it however we like.
There’s no “right way” to build forms in React and there are a lot of options. It’s simple enough to have a working form, but what about validation? Can you rely on the browser’s default validation, or should you write your own state handlers, or drop in a form library?
Formspree has been cranking out new capabilities and fixing bugs. Here’s the latest new features that have dropped over the last few weeks.