I was wondering if there is anyway to know which field was changed when the onChange event is called. This would be pretty useful to avoid unnecessary validations/actions when this event is triggered.
I'm currently writing a Credit Card form, and I'm checking the card number as the user writes it, in order to show the card brand as soon as there are enough numbers to identify it. Right now, I'm using the onChange listener, and I'm looking for the card brand on every change the user makes. It would be way more efficient if this would be done only when the number field is changed.
Is there any way to achieve this?
At present, no, there's no indication of what field changed. A developer can of course check what fields are different between the old state and the current state if they need to, but I feel like in the particular use case you describe, I wouldn't want to compromise the functional approach just for a slight gain in efficiency.
This functionality is needed.
add second attribute that indicates current target?
Most helpful comment
This functionality is needed.