When updating value prop onChange is triggered
See original GitHub issueI would imagine onChange would only be called if the value was changed as a result of a keyboard or click interaction.
But it’s called when the value
prop has changed as well.
Intended, or not?
For now I’m using onValuesUpdated
to let me know if the user is in the process of updating the value, and then resetting it when onChange
is called.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:13
Top Results From Across the Web
React: trigger onChange if input value is changing by state?
I want to change the input value according to state, the value is changing but it doesn't trigger handleChange() method. How can I...
Read more >Simulate React On-Change On Controlled Components
So, onChange event triggers only when we manually update the input value. Try it on CodePen. This Pen is owned by Anulesh Tiwari...
Read more >Trigger Input Updates with React Controlled Inputs - Cory Rylan
Once updated, we dispatch a new change event on the input, so React will trigger a new re-render as the input value will...
Read more >react input onchange doesn't work - You.com | The AI Search ...
I tried putting it inside the onChange prop directly but still no luck and also normally if onChange function doesn't work it doesn't...
Read more >input file'' onchange react - Industry Today
When creating a form with React components, it is common to use an onChange handler to listen for changes to input elements and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
i’ll create an example so we have something to talk about, give me a bit.
We’ve also been dealing with this causing infinite loops, ended with a
nextChangeIsReal
flag to implement @madou 's suggestion. It feels like an unexpected thing for the component do to compared to other controlled components