React-router: Maximum Callstack Exceeded

0

I'm trying to set up routes for my application, but when I'm based on official example in github I get an error of "Maximum Callstack Exceeded" .

I checked everything from point to point and I can not find my error.

Here is my code:

routes.js

'use strict';

import React from 'react';
import auth from './auth';
import { Router, Route, IndexRoute, browserHistory } from 'react-router';

// Global
import AppContainer from '../components/App';

// Login
import LoginForm from '../components/LoginForm';

//Dashboard
import DashboardContainer from '../components/Dashboard';

// Supplier
import SupplierContainer from '../components/Supplier';
import SupplierListContainer from '../components/Supplier/List';


function redirectToLogin(nextState, replace) {
  if (!auth.loggedIn()) {
    replace({
      pathname: '/login',
      state: { nextPathName: nextState.location.pathname }
    });
  }
}

function redirectToDashboard(nextState, replace) {
  if (auth.loggedIn()) {
    replace('/');
  }
}

export const routes =  (
  <Router history={browserHistory}>
    <Route path="/" component={AppContainer}>
      <IndexRoute component={DashboardContainer}/>
      <Route path="dashboard" component={DashboardContainer} onEnter={redirectToLogin} />
      <Route path="supplier" component={SupplierContainer}>
          <IndexRoute component={SupplierListContainer}/>
          <Route path="list" component={SupplierListContainer}/>
        </Route>
      <Route path="login" component={LoginForm} onEnter={redirectToDashboard} />
    </Route>
  </Router>
);

index.js

'use script';

// React
import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import { store } from './utils/storage/store';
import { routes } from './utils/routes';

render(
  <Provider store={store}>
    {routes}
  </Provider>,
  document.getElementById('app')
);

Does anyone have an idea of what's happening?

Thank you in advance

    
asked by anonymous 08.08.2016 / 23:34

0 answers