title: React Routing: Detect route change
body: <p>I'm having trouble detecting route changes with React Router v5. <del>The desire is, when the route changes I want output a console.log.</del> The desire is, when the route changes I want output that route in a console.log in the App component (as shown in the code below) so I can then set a variable in App.js based on the route.</p>
  
  <p>Package versions:</p>
  
  <pre><code>"dependencies": {
     "react": "^16.12.0",
     "react-router-dom": "^5.1.2",
  }
  </code></pre>
  
  <p>This is the App.js code where my router is currently located:</p>
  
  <pre><code>import React from "react";
  import { BrowserRouter as Router, Route, Switch, NavLink } from "react-router-dom"
  import "./App.css";
  import AdminDashboard from "./pages/AdminDashboard"
  import UserList from "./pages/UserList"
  
  function App() {
  
      const routeChange = () =&gt; {
          console.log("foo!")
          console.log(window.location.pathname)
      }
  
      return (
          &lt;&gt;
              &lt;Router onChange={routeChange}&gt;
                  &lt;NavLink exact={true} className="nav-link" to="/AdminDashboard"&gt;Admin Dashboard&lt;/NavLink&gt;
                  &lt;NavLink exact={true} className="nav-link" to="/UserList"&gt;User List&lt;/NavLink&gt;
                  &lt;Switch&gt;
                      &lt;Route path="/AdminDashboard" component={AdminDashboard} exact /&gt;
                      &lt;Route path="/UserList" component={UserList} exact /&gt;
                  &lt;/Switch&gt;
              &lt;/Router&gt;
          &lt;/&gt;
      );
  }
  
  export default App;
  
  </code></pre>