DEV Community

loading...

Discussion on: Practical Tips for Handling Forms in React

Collapse
bendman profile image
Ben Duncan

How do you feel about an onChange handler on the form element, instead of each input?

Collapse
alchermd profile image
John Alcher Author

Honestly, I wasn't aware you can do that. It actually makes perfect sense to add the handler on the form itself and put all custom logic on that generic handler. Though I fiddled around and saw that adding another handler on the input itself won't override the handler on the form element, but instead it'll fire first and then run the form's handler. Not 100% sure of the implications here but it's nice to know.