Skip to content

Why react changed the behaviour of 'onChange' to behave exactly like 'onInput' when there was already onInput available ? #9567

@nikhilgoyal104

Description

@nikhilgoyal104

Here's what the official docs say about onChange:-

The 'onChange' event behaves as you would expect it to: whenever a form field is changed, this event is fired. We intentionally do not use the existing browser behaviour because 'onChange' is a misnomer for its behaviour and React relies on this event to handle user input in real time.

https://facebook.github.io/react/docs/dom-elements.html#onchange

But there is already an event which fires on every keystroke, i.e. 'onInput'. So I don't understand why react changed the behaviour of 'onChange' to behave as 'onInput'. Also in the docs, everywhere 'onChange' is used. Is there any specific reason for it ? Are the two completely interchangeable in react
? Now there is no event with the behaviour of actual 'onchange' . Does react intend to correct this in future ?

Here's the code for that :-

https://jsfiddle.net/nikhilgoyal104ah4/69z2wepo/77518/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions