title: React Router v4 Redirect fails to redirect
body: <p>With <code>onEnter</code> replaced with <code>render</code> I changed my code to match the router v4 specs. The point was to prevent the <code>/signup</code> page from getting displayed when logged in.What do i miss in my code?</p>
  
  <pre><code>import React from 'react';
  import ReactDOM from 'react-dom';
  import {Meteor} from 'meteor/meteor';
  import {BrowserRouter, Route, Redirect, Switch} from 'react-router-dom';
  import browserHistory from 'history';
  import {Tracker} from 'meteor/tracker';
  
  import Signup from '../imports/ui/Signup';
  import MyLink from '../imports/ui/MyLink';
  import NotFound from '../imports/ui/NotFound';
  import Login from '../imports/ui/Login';
  
  const history = browserHistory.createBrowserHistory();
  
  const unathenticatedPages = ['/', '/signup'];
  const athenticatedPages = ['/mylink'];
  const onEnterPublicPage = () =&gt; {
    if (Meteor.userId()) {
      return &lt;Redirect to="/mylink/" /&gt;;
    }
  };
  
  const routes = (
    &lt;BrowserRouter history={history}&gt;
      &lt;Switch&gt;
        &lt;Route exact path="/" component={Login} render={() =&gt; onEnterPublicPage} /&gt;
        &lt;Route path="/signup" component={Signup} render={() =&gt; onEnterPublicPage} /&gt;
        &lt;Route path="/login" component={Login} /&gt;
        &lt;Route path="/mylink" component={MyLink} /&gt;
        &lt;Route path="*" component={NotFound} /&gt;
      &lt;/Switch&gt;
    &lt;/BrowserRouter&gt;
  );
  
  Tracker.autorun(() =&gt; {
    const isAuthenticated = !!Meteor.userId();    
    const pathname = history.location.pathname;
  
    const isUnathenticatedPage = unathenticatedPages.includes(pathname);
    const isAthenticatedPage = athenticatedPages.includes(pathname);
  
    if (isAuthenticated &amp;&amp; isUnathenticatedPage) {
      history.push('/mylink');
    } else if (!isAuthenticated &amp;&amp; isAthenticatedPage) {
      history.push('/');
    }
  });
  
  Meteor.startup(() =&gt; {
    ReactDOM.render(routes, document.getElementById('app'));
  });
  </code></pre>