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.

Option search is being run one change behind

See original GitHub issue

When constructing a Typeahead with an array of strings as the object, each change brings up a list of options reflecting the input node’s value before the change.

'' > no list
'a' > empty list
'ab' > list matching 'a'
'abc' > list matching 'ab'
'ab' [backspace] > list matching 'abc'
'abPASTED_TEXT' > list matching 'ab'
'abPASTED_TEXTc' > list matching 'abPASTED_TEXT'

Based on stepping through, it seems to be because componentWillReceiveProps is using this.state.entryValue to calculate the options, but the setState({entryValue}) in _onTextEntryUpdated hasn’t yet been put into this.state at that point. As a result, even though the correct options are calculated in _onTextEntryUpdated, they’re instantly overridden before the render occurs by a recalculation in componentWillReceiveProps using the previous state.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
alexjgcommented, Dec 9, 2015

@fmoo Is there any chance you could take a look at the above PR which fixes this issue?

0reactions
juanmnlcommented, Oct 20, 2015

I was experiencing this until i removed defaultValue="" from the component props.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React form onChange->setState one step behind
A call to setState isn't synchronous. It creates a "pending state transition." (See here for more details). You should explicitly pass the new...
Read more >
Change settings for the Search Results Web Part
Learn how to change the query and other settings to display search results in the SharePoint Search Results Web Part.
Read more >
Change your VoiceOver settings on iPhone
To set other audio options, go to Settings > Accessibility > VoiceOver > Audio, then set options such as the following: Sounds &...
Read more >
Change site permissions - Computer - Google Chrome Help
On your computer, open Chrome. At the top right, click More More and then Settings. Click Privacy and security and then Site settings....
Read more >
The changing categories the U.S. census has used to ...
And it was not until 2000 that Americans could choose more than one race to describe themselves, allowing for an estimate of the...
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