UNPKG

react-instantsearch-nextjs

Version:
28 lines (25 loc) 1.96 kB
import { useInstantSearchContext, useRSCContext } from 'react-instantsearch-core'; function TriggerSearch() { var _waitForResultsRef_current; var instantsearch = useInstantSearchContext(); var _useRSCContext = useRSCContext(), waitForResultsRef = _useRSCContext.waitForResultsRef, resolveWaitForResultsRef = _useRSCContext.resolveWaitForResultsRef; if ((waitForResultsRef === null || waitForResultsRef === void 0 ? void 0 : (_waitForResultsRef_current = waitForResultsRef.current) === null || _waitForResultsRef_current === void 0 ? void 0 : _waitForResultsRef_current.status) === 'pending') { var _instantsearch_mainHelper; if (instantsearch._hasSearchWidget) { if (instantsearch.compositionID) { var _instantsearch_mainHelper1; (_instantsearch_mainHelper1 = instantsearch.mainHelper) === null || _instantsearch_mainHelper1 === void 0 ? void 0 : _instantsearch_mainHelper1.searchWithComposition(); } else { var _instantsearch_mainHelper2; (_instantsearch_mainHelper2 = instantsearch.mainHelper) === null || _instantsearch_mainHelper2 === void 0 ? void 0 : _instantsearch_mainHelper2.searchOnlyWithDerivedHelpers(); } } instantsearch._hasRecommendWidget && ((_instantsearch_mainHelper = instantsearch.mainHelper) === null || _instantsearch_mainHelper === void 0 ? void 0 : _instantsearch_mainHelper.recommend()); if (!instantsearch._hasSearchWidget && !instantsearch._hasRecommendWidget) { var _resolveWaitForResultsRef_current; resolveWaitForResultsRef === null || resolveWaitForResultsRef === void 0 ? void 0 : (_resolveWaitForResultsRef_current = resolveWaitForResultsRef.current) === null || _resolveWaitForResultsRef_current === void 0 ? void 0 : _resolveWaitForResultsRef_current.call(resolveWaitForResultsRef); } } return null; } export { TriggerSearch };