Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a React component that changes its content based on the value of a hardcoded text input field.

Easy

Problem 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

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;