How to use the react-instantsearch.createConnector function in react-instantsearch

To help you get started, we’ve selected a few react-instantsearch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github algolia / react-instantsearch / packages / react-instantsearch / examples / autocomplete / src / App-Hits-And-Facets.js View on Github external
<div>
          
          
          
          
          
        </div>
      
    );
  }
}

const VirtualSearchBox = connectSearchBox(() =&gt; null);
const VirtualRefinementList = connectRefinementList(() =&gt; null);

const connectAutoComplete = createConnector({
  displayName: 'AutoComplete',

  /*
   We retrieve all the values needed:
   - Current query
   - Hits
   - Facet values (given an array of attributes provided to the component)
   To work properly, you need to use Virtual Widgets for the SearchBox and all the
   facets you want the value of.
   */
  getProvidedProps(props, state, search) {
    const hits = search.results &amp;&amp; search.results.bestbuy
      ? search.results.bestbuy.hits
      : [];
    const facets = props.attributes.reduce((acc, attributeName) =&gt; {
      if (search.results &amp;&amp; search.results.bestbuy) {