Explain the concept of uncontrolled components in React.
Instruction: Describe what uncontrolled components are and when they should be used in React applications.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
An uncontrolled form input keeps its current value in the DOM. React can supply an initial defaultValue or defaultChecked without driving every subsequent edit through a value/checked prop. Read the value through FormData or a ref when the workflow needs it.
import { useState } from 'react'; export default function ContactForm() { const [status, setStatus] = useState(''); function submit(event) { event.preventDefault(); const name = new FormData(event.currentTarget).get('name'); setStatus(typeof name === 'string' && name.trim() ?...