I have saved a query in a DB and recalled it for running again. However, I do not know how re-run the query.
I obtain the query in the onChange and saved the value to the DB as a string for recalling later so it can be worked on.
<ReactiveBase app={this.props.app} url={config.elastic.URL} >
<StateProvider
onChange={(prevState, nextState) => {
queryString = nextState;
console.log('onChange');
}}
I was looking at a way to put that query string in the DataSearch component if that is the correct thing to do. The query is quite large as I have additional components attached to the search.
If I set the value of the DataSearch to my queryString I can not type in the search bar
<DataSearch
dataField={this.props.refinement.searchBar}
componentId="search"
placeholder="Search books or videos"
autosuggest={false}
debounce={debounce}
showClear={true}
customQuery={this.props.customQuery}
defaultValue={this.props.defaultValue}
value={queryString}
>
</DataSearch>
also the query is an elastic search query so I get a search bar full of JSON. I can get the indavidual elements and set queryString to that which gives me half of what I want but with a searchbar I can not type into.
var objectQuery = JSON.parse(selectedQueryString);
queryString = objectQuery.search.value;
Update
This helped in being able to type in the searchBar and update the value and may even be most of the way there for the DataSearch component.
value={this.state.value}
onChange={(value, triggerQuery, event) => {
this.setState(
{
value,
},
() => triggerQuery(),
);
}}