I have two pages. The first one is the homepage and has a search bar. The second one is listing page which shows items which have been searched.
<BrowserRouter>
<div>
<ScrollToTop>
<Route exact path="/" component={Home}/>
<Route path="/tours/" component={Items}/>
</ScrollToTop>
</div>
</BrowserRouter>
in the Items.js, I have another component for search menu.
<SearchOverlayMenu/>
and in SearchOverlayMenu I have a simple form component called SearchOverlayMenuForm like this
<div className="text-right">
<button onClick={this.handleFormSubmit}>
<i className="fa fa-search"></i>
</button>
<input id="query" className="bfont text-right" name="q" type="search"/>
</div>
my problem is when I type a keyword in the query input and press the submit bottom, I can't use NavLink and I also don't have access to this.history.push(...);
and this is my 'handleformsubmit' function in SearchOverlayMenuForm component:
handleFormSubmit() {
let query = document.getElementById('query').value;
console.log(query);
let newurl = '/tours/?q=' + query;
this.history.push(newurl);
}
How I can redirect users to target URL?