react Maximum call stack size exceeded
<p>I trying to redirect the user to the "TrapPage" if he is not logged in.</p>

<p>Here is my code:</p>

<pre><code>function requireAuth(nextState, replace) {
    if (!auth.loggedIn()) {
        replace({ 
            pathname:'/trap'
        })
    }
}

export default (
    &lt;Route path="/" component={App} onEnter={requireAuth}&gt;
        &lt;IndexRoute component={DashboardPage} /&gt;
        &lt;Route path="trap"&gt;
            &lt;IndexRoute component={TrapPage}/&gt;
        &lt;/Route&gt;
        &lt;Route path="accounts"&gt;
            &lt;IndexRoute component={AccountPage}/&gt;
            &lt;Route path="add" component={AccountAdd} /&gt;
            &lt;Route path="detail/:id" component={AccountDetail} /&gt;
        &lt;/Route&gt;
        &lt;Route path="contacts"&gt;
            &lt;Route path="detail/:id" component={ContactPage}/&gt;
        &lt;/Route&gt;
        &lt;Route path="transmissors"&gt;
            &lt;Route path="detail/:id" component={TransmissorPage}/&gt;
        &lt;/Route&gt;
        &lt;Route path="attends" component={AttendancePage} /&gt;
        &lt;Route path="reports" component={ReportPage} /&gt;
        &lt;Route path="configs" component={ConfigurationPage} /&gt;
    &lt;/Route&gt;
);
</code></pre>

<p>When I put the function requireAuth at onEnter, the console gives me an error:</p>

<pre><code>Uncaught RangeError: Maximum call stack size exceeded
</code></pre>

<p>I am a begginer at React, please be patient :)</p>

<p>What is wrong at my code?</p>