I’m starting developing form in React and I’ve made every field of form a separate component. So, from picture below:
Component A – is form with submit function
Component B – is file input (for example)
How to fetch state objects of nested components after clicking Submit button? I know that I can pass function to nested components witch will update parent state but maybe there is better solution?
2
Answers
In React, you have several options for managing and collecting state from nested components when a form is submitted. Here are some common approaches