react-instantsearch-dom#connectStateResults JavaScript Examples

The following examples show how to use react-instantsearch-dom#connectStateResults. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RelatedSolutions.js    From plataforma-sabia with MIT License 6 votes vote down vote up
Results = connectStateResults(({ searchResults, type, current, onChange }) => {
	useEffect(() => {
		if (
			type &&
			typeof searchResults?.nbHits !== 'undefined' &&
			current !== searchResults?.nbHits
		) {
			onChange((old) => ({ ...old, [type]: searchResults?.nbHits }));
		}
	}, [current, onChange, searchResults, type]);
	return null;
})
Example #2
Source File: index.js    From plataforma-sabia with MIT License 6 votes vote down vote up
Results = connectStateResults(({ searchResults, type, current, onChange }) => {
	useEffect(() => {
		if (
			type &&
			typeof searchResults?.nbHits !== 'undefined' &&
			current !== searchResults?.nbHits
		) {
			onChange((old) => ({ ...old, [type]: searchResults?.nbHits }));
		}
	}, [current, onChange, searchResults, type]);
	return null;
})
Example #3
Source File: AlgoliaStateResults.jsx    From emprezzo with MIT License 5 votes vote down vote up
AlgoliaStateResults = connectStateResults(StateResults)
Example #4
Source File: index.js    From emprezzo with MIT License 5 votes vote down vote up
Results = connectStateResults(
  ({ searching, searchState, searchResults: res }) =>
    (searching && <div>Searching...</div>) ||
    (res && res.nbHits === 0 && <div>No results for &apos;{searchState.query}&apos;</div>)
)
Example #5
Source File: index.js    From emprezzo with MIT License 5 votes vote down vote up
Stats = connectStateResults(
  ({ searchResults: res }) =>
    res && res.nbHits > 0 && `${res.nbHits} result${res.nbHits > 1 ? `s` : ``}`
)
Example #6
Source File: index.js    From website with MIT License 5 votes vote down vote up
Results = connectStateResults(
  ({ searchState: state, searchResults: res, children }) =>
    res && res.nbHits > 0 ? children : ""
)
Example #7
Source File: index.js    From learningHub with MIT License 5 votes vote down vote up
Results = connectStateResults(
  ({ searching, searchState: state, searchResults: res }) =>
    (searching && `Searching...`) || (res && res.nbHits === 0 && `No results for '${state.query}'`)
)