algolia / react-instantsearch

⚡️ Lightning-fast search for React and React Native applications, by Algolia.
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/react/
MIT License
1.97k stars 386 forks source link

question: manual connection in react #1789

Closed webmobiles closed 5 years ago

webmobiles commented 5 years ago

question:

actually i'm ussing on my SPA React this code:

// @ts-ignore
import * as client from 'algoliasearch/lite'
const algoliaClient = client(

is this correct? or there are another library for react? i need manual connection from react to work with custome components with and without connects...

thanks

samouss commented 5 years ago

I'm not sure I understand the question. Could you provide a bit more context about what you are trying to do? It will help to better understand the issue.

webmobiles commented 5 years ago

i need to pass the variable index, like I do on api server (using a simple connect to manage index), but in this case for the front and, and then use the index like parameter to pass it to the customizes component , that works with different index like this:

                      <NewAlgoliaSelect
                        onChange={this.selectCustomer}
                        sourceTable="organizations"
                        index={indexOrganizations}
                      />

I'm not sure if 'algoliasearch/lite' is the right library or react-instantsearch provide a way to connect to index (of course without algolia components) just pure connection like on the algolia api for backend.

samouss commented 5 years ago

From what I understand you want to be able to switch between indices with your own component rather than the Algolia one right? You can achieve this with the connectors. There are high order components that abstract the search logic and let you only implement the view. We have a connector that let you switch between indices: connectSortBy. Here is an example on how to use it.

samouss commented 5 years ago

I'm closing this issue because it's inactive since a while. Feel free to open a new one in case you didn't solve your issue!