Answer the question
In order to leave comments, you need to log in
Passing data between unrelated components in react??
There is part of the page
<Header/>
<Switch>
<Route path={/componentOneURL} component={ComponentOne} />
<Route path={/componentTwoURL} component={ComponentTwo} />
</Switch>
<Footer/>
Answer the question
In order to leave comments, you need to log in
I hope the general meaning is clear
const headerTitles = {
'/componentOneURL': 'Component One',
'/componentTwoURL': 'Component Two'
};
const Header = withRouter(({ location }) => <span>{headerTitles[location.pathname]}</span>);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question