Reputation: 105
In the virtual DOM, onChange is triggered every time the content of the input is changed. In the regular DOM, onChange is only triggered when the input element is blurred.
link to GIF illustrating the behavior
sample project:
source code for the above demo
Why does React trigger onChange events differently for virtual DOM elements?
Upvotes: 2
Views: 456
Reputation: 143144
React DOM intentionally deviates and makes onChange fire on every change because that's almost always what you want. This is described in the documentation here: Forms.
Upvotes: 2