Input Box in react
Input Box in react
// Event handler to update the state when the input value changes
const handleInputChange = (event) => {
setInputValue(event.target.value);
};
return (
<form onSubmit={handleSubmit}>
<label>
Your Name:
{/* Controlled Input component */}
<input
type="text"
value={inputValue}
onChange={handleInputChange}
/>
</label>
<br />
{/* Submit button */}
<button type="submit">Submit</button>
</form>
);
};