moroshko / autosuggest-trie

Minimalistic trie implementation for autosuggest and autocomplete components
MIT License
25 stars 4 forks source link

Usage with React Autosuggest #7

Open jaredpalmer opened 7 years ago

jaredpalmer commented 7 years ago

can you show how you might use this with React Autosuggest (assuming I can't download all the data when the component mounts)?

onSuggestionsFetchRequested = ({value}) => {
   CallMySearchApi(value)
   .then(
      results => {
        this.setState({
            suggestions: // shouldn't I be adding to exisiting trie here?
        })  
      },
      error => {}
   )
}
moroshko commented 7 years ago

If you don't have all the data on the client, this means that the matching is done on the server.

In this case, autosuggest-trie will be used only on the server. Your react-autosuggest setup won't have any mention of autosuggest-trie.

Does this make sense?

zero-commit commented 1 year ago

In my opinion, this can be done by storing trie in your database and then calling autosuggest-trie on backend