Skip to content

Instantly share code, notes, and snippets.

@leofab86 leofab86/searchResults.js
Last active May 23, 2019

What would you like to do?
Fuzzy search autocomplete v1.2.2
export default class SearchResults extends React.Component {
constructor (props) {
this.state = {
searchResults: [],
//initiate the webworker:
this.webWorker = new Worker('...path to webWorker.js')
//pass it the 13,000 item search data to initialize the searchEngine with:
//assign the handler that will accept the searchResults when it sends them back:
this.webWorker.onmessage = this.handleResults
componentDidUpdate(prevProps) {
const {searchTerm} = this.props;
if(searchTerm && searchTerm !== prevProps.searchTerm) {
//change our async search request to a .postMessage, the messaging API of webWorkers:
handleResults = (e) => {
const {searchResults} =
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
You can’t perform that action at this time.