appbaseio / reactivesearch

Search UI components for React and Vue
https://opensource.appbase.io/reactivesearch
Apache License 2.0
4.9k stars 466 forks source link

Save Query #319

Closed ymzoughi closed 6 years ago

ymzoughi commented 6 years ago

Issue Type: Help wanted

Platform: ReactiveSearch for Web

Description: is it possible to retrieve the current request to be able to save it ?

Reactivesearch version: x.y.z V2

Browser: [all | Chrome XX | Firefox XX | Edge XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

Anything else:

divyanshu013 commented 6 years ago

Hey @ymzoughi, you can use onQueryChange prop on a component which gives you the previous and current query. For example:

<DataSearch
   ...
   onQueryChange={(prevQuery, nextQuery) => ...}
/>
ymzoughi commented 6 years ago

Exactly, I used onQueryChange, but this one was never executed

<DataSearch
                      componentId="searchbox"
                      dataField="modele"
                      highlightField="modele"
                      categoryField="properties.modele"
                      placeholder="..."
                      onQueryChange={(prevQuery, nextQuery) => console.log(prevQuery, nextQuery)}
                    />
divyanshu013 commented 6 years ago

The query is only fired if some other component is watching this component. For example if you've a ReactiveList with a react prop, the query would get fired. Can you try this?

<DataSearch ... />

<ReactiveList
    ...
    react={{
        and: 'searchbox'
    }}
/>
ymzoughi commented 6 years ago

thank you so much, it works now !!!!