我有一个组件,其中我使用反应式搜索作为一个库来从elastic和onValueSelected中获取数据,将其重定向到结果页面,但是当我将其重定向到Result Components时,它不返回任何内容,甚至不重定向。以下是我的搜索组件
render() {
const { value } = this.state;
console.log("value: ", value);
// this redirect is for routing to results page after user query submission
const { redirect } = this.state;
if (redirect) {
return (
<Link
to={{
pathname: "/results",
search: `?q="${value}"&type="${this.state.value1}"&querytype="${this.state.querytype}"`,
type:this.state.value1,
querytype:this.state.querytype,
valuesearch:value
}}
/>
);
}
return (
<ReactiveBase
// app={this.state.value1}
app="eforms"
url="http://localhost:8111/elasticsearch/">
<form onSubmit={this.handleSubmit}>
<label>
<select value1={this.state.value1} onChange={this.handleChange}>
<option value1="_all">All</option>
<option value1="eforms">Eforms</option>
<option value1="complaints">Complaints</option>
</select>
</label>
</form>
<div className="flex row-reverse app-container">
<div className="results-container">
<DataSearch
componentId="q"
dataField={["eform_ticket_num","eform_ticket_num.search"]}
URLParams={true}
placeholder="Search for notes..."
className="search-box"
onValueSelected={(value, cause, source) => {
console.log("suggestion selected: ", value, cause);
if (cause !== "SUGGESTION_SELECT") {
// use this query
this.state.querytype="Like"
console.log(
"use this query - onValueSelected: ",
this.query
);
this.setState({ redirect: true, value: value });
// this.props.history.push(`/?q="${value}"`);
} else {
this.valueSelected = true;
this.state.querytype="exact"
this.setState({ value });
}
}}
onQueryChange={(prevQuery, nextQuery) => {
this.query = nextQuery;
if (this.valueSelected) {
console.log(
"use this query - onQueryChange: ",
this.query
);
this.valueSelected = false;
this.setState({
redirect: true
});
}
}}
/>
</div>
</div>
</ReactiveBase>
);
}
}
下面是我的路线提交:
<Route path="/results" component={Results} />
我无法弄清楚为什么Link to不能像我以前使用的那样工作。