Reacting to input with state in code
const [name, setName] = useState("");
const [error, setError] = useState<string | null>(null);
<input
value={name}
onChange={e => setName(e.target.value)}
onBlur={() => setError(name.trim() ? null : "Required")}
onFocus={() => setError(null)}
/>;Read the example from data and control flow to the resulting UI. Keep the component boundary small.