Я придумал другой подход без необходимости отслеживать location
, как в другом посте, - надеюсь, он может кому-то помочь:
<Router>
<Switch>
<Route exact path="/" component={Home} />
<Route render={() =>
<>
<Header /> // --> header component will be present whenever a route is not matching the '/' route
<Switch>
<Route path="/about" component={About} />
<Route path="/users" component={Users} />
</Switch>
</>
}} />
</Switch>
</Router>