question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When updating value prop onChange is triggered

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:13

github_iconTop GitHub Comments

2reactions
itsdougescommented, Jan 16, 2018

i’ll create an example so we have something to talk about, give me a bit.

0reactions
neil-morrison44commented, Jul 6, 2018

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found