What type of form component is this, and how does the value of the input field behave?
function MyForm() {
const [inputValue, setInputValue] = useState("");
const handleChange = (event) => {
setInputValue(event.target.value);
};
return (
<form>
<input type="text" value={inputValue} onChange={handleChange} />
<p>Current Value: {inputValue}</p>
</form>
);
}
Uncontrolled, value managed by DOM
Controlled, value managed by React state
Uncontrolled, no state
Controlled, value not changeable
This question is part of this quiz :
React Forms