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
00:00
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;
Input
Initial input value: 'Hello'
Expected Output
The <p> tag updates dynamically as the user types.