How to use the react-instantsearch/connectors.connectStateResults 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 / search-insights.js / examples / react-instantsearch / src / App.js View on Github external
import {
  connectStateResults,
  connectHits,
} from 'react-instantsearch/connectors';
// import './App.css';

const Analytics = connectStateResults(({ searchResults }) => {
  window.aa('initSearch', {
    getQueryID: () => searchResults && searchResults._rawResults[0].queryID,
  });

  return null;
});

const Hits = connectHits(
  connectStateResults(({ hits, searchResults }) => (
    <div>
      {hits.map((hit, index) =&gt; (
        <div>
          
          <button> {
              window.aa('click', {
                objectID: hit.objectID,
                position:
                  searchResults.hitsPerPage * searchResults.page + index + 1,
              });
            }}
          &gt;
            Click event
          </button>
          </div></div>
github EnMarche / transformer.en-marche.fr / src / js / components / theme.js View on Github external
import React from 'react';
import { groupBy, filter } from 'lodash';
import { Measures, NoMeasure } from './measure';
import { connectStateResults } from 'react-instantsearch/connectors';

import './../../scss/theme.css';
  
const Theme = connectStateResults(({ hit:theme, searchState: { query } }) =&gt; {
  let { measures } = theme;

  measures = filter(measures, m =&gt; m.title.match(new RegExp(query, 'gi')));
  let grouped = groupBy(measures, 'status');
  measures = (grouped['DONE'] || [])
                .concat(grouped['IN_PROGRESS'] || [])
                .concat(grouped['UPCOMING'] || []);
  
  if (query &amp;&amp; !measures.length) {
    // no matching measures for this keyword query
    // return nothing so it doesn't render
    return null;
  }
  
  return (
    <article></article>
github prescottprue / fireadmin / src / components / UsersSearch / SearchResults.js View on Github external
) : null

SearchResults.propTypes = {
  searchState: PropTypes.shape({
    // from connectStateResults
    query: PropTypes.string
  }),
  resultsTitle: PropTypes.string,
  onSuggestionClick: PropTypes.func.isRequired,
  // hits: PropTypes.object, // from react-instantsearch
  searchResults: PropTypes.object // from connectStateResults
}

export default connectStateResults(SearchResults)
github BeeDesignLLC / GlutenProject.com / components / SearchBox.js View on Github external
&gt;
              {searchResults.nbHits} results
            
          )}

        
          <a color="white">
            
          </a>
        
      
    )
  }
}

export default withRouter(connectSearchBox(connectStateResults(SearchBox)))
github EnMarche / transformer.en-marche.fr / src / js / components / themes.js View on Github external
)}
                {measuresComponent}
            
        )
    }
}

ThemeDetail = connect(
    ({
        majorOnly,
        locale,
        profiles: { activeProfile },
        measures: { measures },
        manifestos: { activeManifestos },
    }) =&gt; ({ majorOnly, measures, activeProfile, activeManifestos, locale })
)(connectStateResults(ThemeDetail))

export { ThemeDetail }
github joshwcomeau / guppy / src / components / DependencyManagementPane / AddDependencyModal.js View on Github external
}

const Wrapper = styled.div`
  height: 100%;
  display: flex;
  flex-direction: column;
`;

const HitsWrapper = styled.div`
  flex: 1;
  padding: 25px;
  padding-top: 0;
  overflow: auto;
`;

export default connectStateResults(AddDependencyModal);
github EnMarche / transformer.en-marche.fr / src / js / components / results.js View on Github external
? !!refinementList[`titles.${locale}`].length
            : false
        return (
            <div>
                
                
            </div>
        )
    }
}

export default connectStateResults(Results)
github BeeDesignLLC / GlutenProject.com / components / Layout.js View on Github external
<a>Legal</a>
          
          
            <a>Privacy Policy</a>
          
          
            <a>Affiliate Disclosure</a>
          
          <a href="https://github.com/BeeDesignLLC/GlutenProject.com">Source Code</a>
        
      
    )
  }
}

export default withRouter(connectStateResults(Page))
github PaulRosset / awesome-list-pretty / src / components / Body.js View on Github external
display: flex;
  flex-direction: column;
  margin: 10px 0;
`;

const Body = ({ searchState, searchResults }) =&gt; (
  
    {searchResults &amp;&amp; searchResults.nbHits !== 0 ? (
      
    ) : (
      <p>No results has been found for {searchState.query}</p>
    )}
  
);

export const WrappedBody = connectStateResults(Body);

export const Resulting = ({ hit }) =&gt; (
  
    
    
      <title>
        &lt;Awesome&gt;awesome&lt;/Awesome&gt; {hit.listName}
      </title>
      {hit.cat}
      
      
        
      
    
  
);