mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-21 01:53:26 +00:00
Fix composition with plugin reducers
This commit is contained in:
@@ -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))
|
||||
);
|
||||
|
||||
@@ -3,7 +3,6 @@ const ACTION_TYPES = require('../actions/TYPES');
|
||||
|
||||
function reduceComponents(state, action) {
|
||||
state = state || List();
|
||||
|
||||
switch (action.type) {
|
||||
|
||||
case ACTION_TYPES.REGISTER_COMPONENT:
|
||||
|
||||
Reference in New Issue
Block a user