title: React router get current location on main router component
body: <p>I'd like to know how to get the current location from the component I've used to define my routes. For example, I have a component called Routes, which contains all the routes, like this:</p>
  
  <pre><code>class Routes extends React.Component {
      render() {
          return (
              &lt;Router&gt;
                  &lt;Nav /&gt;
                  &lt;header&gt;{customHeader}&lt;/header&gt;
                  &lt;Switch&gt;
                      &lt;Route exact path="/" component={Home} /&gt;
                      &lt;Route path="/about" component={About} /&gt;
                      // Other routes
                  &lt;/Switch&gt;
              &lt;/Router&gt;
          );
      }
  };
  </code></pre>
  
  <p>However, when I try to access <code>this.props.location.pathname</code> as I do in other components, it returns <code>undefined</code>.</p>
  
  <p>On the other components I need to use <code>withRouter</code> in order to be able to access the <code>location</code> information. But I can't use it with the <code>Routes</code> component, because it will throw an error.</p>
  
  <p>I don't actually need the <code>pathname</code>, I just want to check what route the user is, because I'll render a different header content when accessing a specific page.</p>