React: Bug: React 16 no longer supports triggering form input change/input events programmatically

Created on 23 Aug 2020  路  7Comments  路  Source: facebook/react

React version: 16.x.x

Steps To Reproduce

Link to code example:

Please, see this example. Notice that the the console has no logs since the change event can't be programmatically triggered.

The current behavior

linkin React 16.x.x

The expected behavior

link in React 16.x.x

Unconfirmed

Most helpful comment

This is relying on an internal flag which was never a part of the public API (so it was not expected to work). That solution is wrong.

Here's a version that works and doesn't rely on this flag: https://codesandbox.io/s/serene-snyder-l3sj0?file=/src/App.js

All 7 comments

This is relying on an internal flag which was never a part of the public API (so it was not expected to work). That solution is wrong.

Here's a version that works and doesn't rely on this flag: https://codesandbox.io/s/serene-snyder-l3sj0?file=/src/App.js

Thanks @gaearon

Please @gaearon what about for a <select/> tag ? How does one programmatically trigger a chnage event on a <select /> tag.

@isocroft Is this the behavior you're looking for? https://codesandbox.io/s/summer-wave-p634m?file=/src/App.js

Yes, it is... I did figure it out myself here earlier than you replied. But, i will be using your version for my needs. It's much more compact and better written than mine.

Thanks a lot @samie820

My pleasure! @isocroft

Was this page helpful?
0 / 5 - 0 ratings