Answer the question
In order to leave comments, you need to log in
React router how to check site header url for route match using match?
prompt, there is a structure of routes and there is a Heading the general for all pages. How can I check if the current page is favorites via match, i.e. for /favorites/ /favorites/n and display the correct class?
render() {
return (
<Router>
<div className="app">
<AppHeader/>
<Switch>
<Route exact path="/" component={NowPlayingPage}/>
<Route path="/page/:page" component={NowPlayingPage}/>
}}
/>
<Route path="/movie/:id" component={MoviePage}/>
}}/>
<Route path="/favorites/:page?" component={FavoriteMoviePage}/>
}}/>
<Route component={Page404}/>
</Switch>
</div>
<AppFooter/>
</Router>
);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question