Write a React component that changes its content based on the value of a hardcoded text input field.
EasyProblem Statement
Write a React component that changes its content based on the value of a hardcoded text input field.
Sample Input
Initial input value: 'Hello'
Sample Output
The <p> tag updates dynamically as the user types.
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 DynamicText = () => { const [text, setText] = useState("Hello"); return ( <div> <input type="text" value={text} onChange={(e) => { // Update the state with the input value }} /> <p>{text}</p> </div> ); }; export default DynamicText;