|
@@ -2,12 +2,12 @@
|
|
|
|
|
|
// Import dependencies
|
|
|
import React from 'react'
|
|
|
-import { createStore, applyMiddleware, combineReducers, bindActionCreators, compose } from 'redux'
|
|
|
-import { Provider, connect } from 'react-redux'
|
|
|
+// import { createStore, applyMiddleware, combineReducers, bindActionCreators, compose } from 'redux'
|
|
|
+// import { Provider, connect } from 'react-redux'
|
|
|
+import { syncHistoryWithStore, routerReducer } from 'react-router-redux'
|
|
|
import createSagaMiddleware from 'redux-saga'
|
|
|
import { all } from 'redux-saga/effects'
|
|
|
import { browserHistory, Router, Route, IndexRoute } from 'react-router'
|
|
|
-import { syncHistoryWithStore, routerReducer } from 'react-router-redux'
|
|
|
|
|
|
class Container {
|
|
|
constructor () {
|
|
@@ -59,7 +59,17 @@ class Container {
|
|
|
applyMiddleware(...this.middleware))
|
|
|
: compose(applyMiddleware(...this.middleware))
|
|
|
|
|
|
- if (withRedux) {
|
|
|
+ // https://github.com/reactjs/redux/issues/1287
|
|
|
+ if (withRouter) {
|
|
|
+ const { BrowserRouter } = require('react-router')
|
|
|
+ const Root = () => (
|
|
|
+ <BrowserRouter />
|
|
|
+ )
|
|
|
+ }
|
|
|
+ if (withRedux || withRouter) {
|
|
|
+ const { createStore, applyMiddleware, combineReducers, bindActionCreators, compose } = require('redux')
|
|
|
+ const { Provider, connect } = require('react-redux')
|
|
|
+
|
|
|
/** The default state is combined from all sub-module states */
|
|
|
const defaultState = { ...this.states }
|
|
|
/** The root reducer is combined from all sub-module reducers */
|
|
@@ -68,6 +78,8 @@ class Container {
|
|
|
const actionCreators = { ...this.actionCreators }
|
|
|
const store = createStore(rootReducer, defaultState, enhancer)
|
|
|
const history = syncHistoryWithStore(browserHistory, store)
|
|
|
+ } else if (withRedux) {
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/** The root saga, calling all other sagas */
|
|
@@ -88,7 +100,7 @@ class Container {
|
|
|
return propState
|
|
|
}
|
|
|
|
|
|
- function mapDispatchToProps (dispatch) {
|
|
|
+ const mapDispatchToProps = function (dispatch) {
|
|
|
const boundActionCreators = {}
|
|
|
Object.keys(actionCreators).forEach(key => {
|
|
|
boundActionCreators[`${key}Actions`] = bindActionCreators(actionCreators[key], dispatch)
|