Form Using TextArea field
A TextArea is a larger text input field. It allows the user to enter multiple lines of text. We can add a TextArea in React using the <textarea> tag but to change its value we have to use the useState hook.
Example: This example implements a form using the TextArea input field.
Javascript
// Filename - App.js import React, { useState } from "react" ; export default function App() { const [value, setValue] = useState( "" ); return ( <div> <h2>w3wiki - ReactJs Form</h2> <form> <label> Input Field:- <textarea value={value} onChange={(e) => { setValue(e.value); }} /> </label> </form> </div> ); } |
Step to run the application: Start the application using the following command:
npm run start
Output: This output will be visible on the http://localhost:3000/ on the browser window.:
Working with Forms in React
React Forms are an important part of most web applications. They allow users to input data and interact with the application. Forms are used to collect the data from the user and process it as required whether in login-signup forms or surveys etc.