React | React Forms| Question 7

Last Updated :
Discuss
Comments

What type of form component is this, and how does the value of the input field behave?

JavaScript
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

Share your thoughts in the comments