Exemplo n.º 1
0
onready(() => {
  var store = configureStore(window.REDUX_INITIAL_STATE || {});

  window.REDUX_INITIAL_STATE = null;

  /**
   *  Watch location changes
   */
  browserHistory.listen(location => {
    var state = store.getState();

    location = location.pathname + location.search;

    location = location.replace(/[?]$/, '');
    if (!location.match(/^\/(en|ru)/)) {
      location = location.replace(/^\/(en|ru)/, '');
      location = '/' + state.lang + location;
    }

    if (state.location == location) {
      return;
    }
    
    store.dispatch(setLocation(location));
  });

  ReactDOM.render(
    <Provider store={store}>
      <Router history={browserHistory}>
        {routes(store)}
      </Router>
    </Provider>,
    document.getElementById('react-root')
  );
});
Exemplo n.º 2
0
});

onready(() => {
  ReactDOM.render(
    <Router history={browserHistory}>

      <Route path={'ru/admin/'} component={App}>
        <IndexRoute component={Storage} />

        <Route path='photos/' component={Photos} />
        <Route path='pages/:page_type' component={PagesList} />
        <Route path='pages/:page_type/:page_id' component={PageEditor} />
        <Route path='storage' component={Storage} />
        <Route path='*' component={Storage} />
      </Route>

      <Route path={'en/admin/'} component={App}>
        <IndexRoute component={Storage} />

        <Route path='photos/' component={Photos} />
        <Route path='pages/:page_type' component={PagesList} />
        <Route path='pages/:page_type/:page_id' component={PageEditor} />
        <Route path='storage' component={Storage} />
        <Route path='*' component={Storage} />
      </Route>
      
      <Route path='*' component={NotFound} />
    </Router>,
    document.getElementById('react-root')
  );
});