+1 vote
82 views
by (98.9k points)
Explain Forms and their types with examples

1 Answer

0 votes
by (98.9k points)
 
Best answer
Forms are an integral part of any modern web application. It allows the users to interact with the application as well as gather information from the users. Forms can perform many tasks that depend on the nature of your business requirements and logic. React offers a stateful, reactive approach to building a form. The component rather than the DOM usually handles the React form.

There are two types of form input in React.

Uncontrolled components-

It is similar to the traditional HTML form inputs. Here, the form data is handled by the DOM itself. It maintains its own state and will be updated when the input value changes. To write an uncontrolled component, there is no need to write an event handler for every state update, and you can use a ref to access the value of the form from the DOM.

Controlled components-

A controlled component is bound to a value, and its changes will be handled in code by using event-based callbacks. Here, the input form element is handled by the react itself rather than the DOM. In this, the mutable state is kept in the state property and will be updated only with the setState() method.

Related questions

0 votes
0 answers 53 views
+1 vote
1 answer 261 views
+1 vote
0 answers 78 views
+1 vote
1 answer 163 views
+1 vote
0 answers 360 views

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

554 users

...