-
-
Save vvo/771d86353bdc5908e6e720fb512dea29 to your computer and use it in GitHub Desktop.
Example of doing multiple indices search using react-instantsearch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
InstantSearch, | |
SearchBox as OriginalSearchBox, | |
Hits | |
} from 'react-instantsearch'; | |
import createConnector from 'react-instantsearch/src/core/createConnector.js'; | |
const UseParentQuery = OriginalSearchBox.connect(() => null); | |
const Nested = createConnector({ | |
displayName: 'Nested', | |
getProps: (props, state) => ({ | |
parentState: state, | |
}), | |
})(props => { | |
return <InstantSearch | |
appId="latency" | |
apiKey="6be0576ff61c053d5f9a3225e2a90f76" | |
indexName="ikea" | |
state={props.parentState} | |
onStateChange={() => {}} | |
createURL={() => {}} | |
> | |
<div> | |
<UseParentQuery/> | |
<Hits/> | |
</div> | |
</InstantSearch>; | |
}); | |
// then you can nest <Nested/> anywhere |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment