How to display data entered by the user in another textbox in React?
Learn how to display user input dynamically in another element using useState and controlled components.
beginnerComponent communicationreactformsuseStatecontrolled component
Published: 10/26/2025
Updated: 10/26/2025
Question
How to display data entered by the user in another textbox in React?
Answer
You can achieve this using React’s useState hook to store and mirror the user’s input.
import { useState } from 'react';
function MirrorInput() {
const [text, setText] = useState('');
return (
<div>
<input
type='text'
value={text}
placeholder='Type something...'
onChange={(e) => setText(e.target.value)}
/>
<input type='text' value={text} readOnly placeholder='Mirror input' />
</div>
);
}
Here, both inputs share the same state (text), so changes in one are reflected in the other.
Real-World Example
Useful for:
- Live preview fields
- Mirroring input for formatted display
- Form debugging tools
Quick Practice
Build a component that mirrors a user’s name input and displays a live greeting message below.
Summary
Use useState to store user input and mirror that state in any other UI element.
Related Videos
Watch these videos to learn more about this topic
Frequently Asked Questions
What’s a controlled component?
A component whose form data is managed by React state.
Can I display input data immediately?
Yes, by syncing state to another element or input.
Stay Updated
Get the latest frontend challenges, interview questions and tutorials delivered to your inbox.