Published on

TMIL: Using the "value" attribute in forms with React

Authors

In React, <input type="text">, <textarea>, and <select> all work very similarly - they all accept a value attribute that you can use to implement a Controlled Component.

In HTML, these elements maintain their own state and update it based on user input but in React, mutable state is typically kept in the state property of components, and only updated with setState().

If we combine these two by making the React state be the “single source of truth” we call it a Controlled Component.

Resources

Blog ideas

Here are some ideas I got as potential blog posts: