Controlled Textareas
You'll learn how React textareas differ from HTML textareas and work just like controlled text inputs.
The HTML vs React Difference
In plain HTML, a <textarea> element uses its children to set the value:
<textarea>Some initial text here</textarea>
But React does things differently. In React, textareas use the value prop instead of children, making them work identically to <input type="text">.
The React Pattern
A controlled textarea follows the exact same pattern you learned for text inputs:
function CommentForm() {
const [comment, setComment] = useState('');
return (
<textarea
value={comment}
onChange={(e) => setComment(e.target.value)}
/>
);
}
Notice:
- The
valueprop (not children between tags) controls what appears - The
onChangehandler updates state withevent.target.value - The textarea is self-closing or has empty children
Why This Design?
By treating textareas like inputs, React gives you a consistent API. Whether you're working with <input>, <textarea>, or (later) <select>, the controlled component pattern stays the same: value + onChange + useState.
This uniformity makes form handling predictable. You don't need to remember special cases—every text-based form element follows the same rules.
Key Takeaway: React textareas use the value prop instead of children, making them work identically to controlled text inputs with the same value + onChange + useState pattern.