Skip to content
Advertisement

How to get form values from multiple child components?

I have a large HTML Form and it has multiple fields in multiple components.

All these components are in a Parent Component.

How Can I submit a form and getting values from all child components?

JavaScript

Advertisement

Answer

you can pass a handler function in the subcomponents(child components) that gets triggered when anything changes and updates the state in the parent component eg:

JavaScript

handler function onChangeHandlerFn={this.onChangeHandlerFn}, should be called if anything is changed in the child components, which intern updates the state of the parent component

Hope this helps !!

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement