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.

SelectSearch ignores not changed value after async onChange

See original GitHub issue

Hi!

It seems that SelectSearch ignores not updated value prop after async onChange.

Let say the value is ‘1’, onChange calls API and (after validation or whatever reason) value didn’t actually update then SelectSearch still shows previously clicked option as a selected one. Which is wrong. So it looks like the internal state is not updated and it mismatches with the provided value from now on.

My workaround is to use a key prop but it’s masking the actual problem in the end. 🤷🏻

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
tbleckertcommented, Apr 20, 2021

Sorry for the late reply @Ronny25 . Yes, seems like something has broken with the controllable state. I’ll take a look

0reactions
Ronny25commented, Apr 3, 2021

@icaroscherma onSelect will be triggered only when value has changed - it means when it’s a primitive string it won’t detect change (when it has previous value). So I would maybe stick to using key prop. Seems a bit cleaner as for me instead of using additional state or monkeypatching. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Returning correct value using react-select and react-hook-form
This solution had a problem with the onChange function for me - what fixed it was using render={({ field }) and then on...
Read more >
react-select-search - Bountysource
It seems that SelectSearch ignores not updated value prop after async onChange . Let say the value is '1', onChange calls API and...
Read more >
SCR19: Using an onchange event on a select element ... - W3C
Navigate to the trigger select element, navigate through the options but do not change the value. Check that the matching option values are...
Read more >
React Select Options Array
Called when select an option or input value change, or value of input is ... How To Get Input Value In JavascriptThe following...
Read more >
React Select Options Array - Azienda Roberto e Nicola Ercolani
How To Get Input Value In JavascriptThe following example displays the. ... React Select onChange, how to change one value of an array...
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