Languages

React - form submit button in root component

3 points
Asked by:
kwartz
1060

How do I implement submit button on the root component which has several child components that has a part of a form?

2 answers
4 points
Answered by:
Root-ssh
178290

In this article you should find the solution.

Finally you can use it this way:

 

Sources

  1. React - optimal way to create form (uncontrolled components) 
2 comments
kwartz
2y
what if I want to handle state individually for each component. How to I go about that?
Root-ssh
2y
You should use useState() for each field and exchange state with use context() or events in child components
Add comment
1 points
Answered by:
Root-ssh
178290

The solution that stores each field in the separated state:

 

See also

  1. React - form with useState example (controlled components)

  2. React - change state from props (functional component)

  3. React - form example (uncontrolled components)

0 commentsAdd comment
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join