Last active
May 23, 2019 17:03
-
-
Save leofab86/9b210112a5dcc9f1203e7fce2a6990ef to your computer and use it in GitHub Desktop.
Fuzzy search autocomplete v1.1.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//searchResults.js | |
componentDidUpdate(prevProps) { | |
const {searchTerm, searchEngine} = this.props; | |
if(searchTerm && searchTerm !== prevProps.searchTerm) { | |
/* stick the update with the expensive search method into | |
a promise callback: */ | |
Promise.resolve().then(() => { | |
this.setState({ | |
searchResults: searchEngine.search(searchTerm) | |
}) | |
}) | |
} | |
} | |
render () { | |
return <ReactVirtualizedList searchResults={this.state.searchResults}/> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment