diff options
Diffstat (limited to 'packages/gitbook-core/src/createStore.js')
-rw-r--r-- | packages/gitbook-core/src/createStore.js | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/packages/gitbook-core/src/createStore.js b/packages/gitbook-core/src/createStore.js index 4873190..6f90b77 100644 --- a/packages/gitbook-core/src/createStore.js +++ b/packages/gitbook-core/src/createStore.js @@ -1,7 +1,7 @@ const Redux = require('redux'); const ReduxThunk = require('redux-thunk').default; -const reducers = require('./reducers'); +const coreReducers = require('./reducers'); /** * Create a new redux store from an initial state and a list of plugins. @@ -13,10 +13,13 @@ const reducers = require('./reducers'); */ function createStore(plugins, initialState) { const pluginReducers = plugins.map(plugin => plugin.onReduceState); - console.log(pluginReducers); - const reducer = Redux.compose(reducers, ...pluginReducers); const store = Redux.createStore( - reducers, + (state, action) => { + return pluginReducers.reduce( + (newState, reducer) => reducer(newState, action), + coreReducers(state, action) + ); + }, initialState, Redux.compose(Redux.applyMiddleware(ReduxThunk)) ); |