title: React-Router v4 onEnter replacement
body: <p>I'm currently trying to build a simple react-redux app that has student and campus data in the backend. OnEnter used to work here, but it doesn't exist in the new react-router. </p>
  
  <p>This app tries to load initial data at the start instead of doing a componentDidMount in each actual component. Is that the recommended approach, or are there alternative patterns that I'm not aware of?</p>
  
  <pre><code>/* -------------------&lt;    COMPONENT   &gt;------------------- */
  import React from 'react';
  
  import { BrowserRouter as Router, Route } from 'react-router-dom';
  import Home from './components/Home';
  import Students from './components/Students';
  
  const Routes = ({ getInitialData }) =&gt; {
    return (
      &lt;Router&gt;
        &lt;div&gt;
          &lt;Route exact path="/" component={Home} onEnter={getInitialData} /&gt;
          &lt;Route path="/students" component={Students} /&gt;
          &lt;Route path="*" component={Home} /&gt;
        &lt;/div&gt;
      &lt;/Router&gt;
    );
  };
  
  /* -------------------&lt;   CONTAINER   &gt;-------------------- */
  
  import { connect } from 'react-redux';
  import receiveStudents from './reducers/student';
  import receiveCampuses from './reducers/campus';
  
  const mapState = null;
  const mapDispatch = dispatch =&gt; ({
    getInitialData: () =&gt; {
      dispatch(receiveStudents());
      dispatch(receiveCampuses());
    }
  });
  
  export default connect(mapState, mapDispatch)(Routes);
  </code></pre>