Create a React form with an input field and a submit button that logs the input value to the console.
EasyProblem Statement
Create a React form with an input field and a submit button that logs the input value to the console.
Sample Input
Hardcoded initial input value: 'React'
Sample Output
Console log: Input value: React (when the form is submitted)
Limits
Time: 2s · Memory: 256 MB
Code Editor
Log in to submit00:00
Try your code in this preview. Submit marks it done.
import React, { useState } from "react"; const InputForm = () => { const [inputValue, setInputValue] = useState("React"); const handleSubmit = (e) => { e.preventDefault(); // Log the input value to the console }; return ( <form onSubmit={handleSubmit}> <input type="text" value={inputValue} onChange={(e) => setInputValue(e.target.value)} /> <button type="submit">Submit</button> </form> ); }; export default InputForm;