Answer the question
In order to leave comments, you need to log in
How to display a component that is not registered with Route?
Good day!
There is a search field in the header and a search button, now I'm trying to change the url on click like this:
window.history.pushState(null, null, '/search');
he is changing!
But this route does not work out
the code structure in the App is like this<Route path="/search" component={SearchResult}/>
<Router>
<div className='app'>
<Header onSearch={this.handleSearch}/>
<main>
<Switch>
<Route exact path="/" component={Home}/>
<Route path="/search" component={SearchResult}/>
<Route path="/registration" component={Registration}/>
<Route path="/login" component={Login}/>
<Route component={NotFound}/>
</Switch>
</main>
</div>
</Router>
Answer the question
In order to leave comments, you need to log in
Since the Header does not participate in the routing, I cannot pass it to Search props.history and call a push on it already, and not as it is now directly!
export default withRouter(Header);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question