Working with textarea in React
Now let's learn how to work with a multi-line input field textarea. In React, working with it, for convenience, is made similar to working with a text input. Unlike pure JS, in React, textarea does not need a closing tag, and its text should be placed in the value attribute.
See example:
function App() {
const [value, setValue] = useState('');
function handleChange(event) {
setValue(event.target.value);
}
return <div>
<textarea value={value} onChange={handleChange} />
<p>{value}</p>
</div>;
}
In abbreviated form:
function App() {
const [value, setValue] = useState('');
return <div>
<textarea value={value} onChange={event => setValue(event.target.value)} />
<p>{value}</p>
</div>;
}
Let the text be entered in textarea. Make it so that the transliteration of the entered text is output to the paragraph.
Let textarea enter numbers on each line. Make it so that as you type, the sum of the numbers entered is displayed in the paragraph.