TIL... How to handle User input with a generic function
While writing a CRUD screen with validation in React, I found I was writing similar, if not the same state-altering functions for each input box. Some functions needed additional validation while others did not. After discussing some team-members, the suggestion was made to use the following:
Paired with code like this for the inputs:
Then just set the name property on the tag to the same property name in state.