Skip to content

Commit

Permalink
move createRouter into rootView, move rootView
Browse files Browse the repository at this point in the history
  • Loading branch information
FredericHeem committed Apr 12, 2017
1 parent 5c6c881 commit 59eecaa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion client/src/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import formatter from 'utils/formatter';
import intl from 'utils/intl';
import Jwt from 'utils/jwt';

import rootView from './redux/rootView';
import rootView from './rootView';
import theme from './theme';

import notification from './utils/notification';
Expand Down
15 changes: 2 additions & 13 deletions client/src/app/parts/core/coreModule.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import _ from 'lodash';
import React from 'react';
import { browserHistory, Router } from 'react-router';
import { syncHistoryWithStore, routerMiddleware } from 'react-router-redux';
import { browserHistory } from 'react-router';
import { routerMiddleware } from 'react-router-redux';
import {createAction, createReducer} from 'redux-act';
import {ASYNC_META} from 'redux-act-async';
import notificationMsg from './components/notificationMsg';
Expand Down Expand Up @@ -35,16 +35,6 @@ function Containers(/*context*/){
}
}

function createRouter(store, routes){
const history = syncHistoryWithStore(browserHistory, store)

history.listen(location => {
debug('routing to ', location)
})

return <Router history={history} routes={routes} />
}

// Part
export default function({context}) {
const actions = Actions();
Expand Down Expand Up @@ -78,7 +68,6 @@ export default function({context}) {
actions,
reducers: Reducers(actions),
containers: Containers(context, actions),
createRouter,
middlewares
}
}
17 changes: 14 additions & 3 deletions client/src/app/redux/rootView.js → client/src/app/rootView.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
import React from 'react';
import { Provider } from 'react-redux'
import Alert from 'react-s-alert';

import Routes from '../routes'
import { browserHistory, Router } from 'react-router';
import { syncHistoryWithStore } from 'react-router-redux';
import Routes from './routes'

import Debug from 'debug';
const debug = new Debug("rootView");

function createRouter(store, routes){
const history = syncHistoryWithStore(browserHistory, store)

history.listen(location => {
debug('routing to ', location)
})

return <Router history={history} routes={routes} />
}

export default function RootView(context, store, parts){
debug('init');
const routes = Routes(context, store, parts)
const Router = parts.core.createRouter(store, routes);
const Router = createRouter(store, routes);
return (
<Provider store={store}>
<div style={{ height: '100%' }}>
Expand Down

0 comments on commit 59eecaa

Please sign in to comment.