I would like to have the original HTML event in my onChange callback.
I need to read some data from the event, like the name of the component.
Examples
I need to make a single change callback for all the text fields in a form and for this I need to know the name of the property to update.
const handleChange = useCallback((value)=>{
const name = // just guess the name of the field or some magic
setFormData(prev =>({...prev, [name]:value})
},[])
This name can be found in the event object. So I propose that we get the original event as the second parameter like so:
Latest version
Description
I would like to have the original HTML event in my
onChange
callback. I need to read some data from the event, like the name of the component.Examples
I need to make a single change callback for all the text fields in a form and for this I need to know the name of the property to update.
This
name
can be found in theevent
object. So I propose that we get the original event as the second parameter like so: