Use combineReducers
This commit is contained in:
parent
37840c2abb
commit
b69cc04856
2 changed files with 16 additions and 40 deletions
|
@ -1,17 +1,8 @@
|
||||||
import settingReducer from './setting';
|
import { combineReducers } from 'redux';
|
||||||
import findReducer from './find';
|
import setting from './setting';
|
||||||
import tabReducer from './tab';
|
import find from './find';
|
||||||
|
import tab from './tab';
|
||||||
|
|
||||||
// Make setting reducer instead of re-use
|
export default combineReducers({
|
||||||
const defaultState = {
|
setting, find, tab,
|
||||||
setting: settingReducer(undefined, {}),
|
});
|
||||||
find: findReducer(undefined, {}),
|
|
||||||
tab: tabReducer(undefined, {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function reducer(state = defaultState, action = {}) {
|
|
||||||
return { ...state,
|
|
||||||
setting: settingReducer(state.setting, action),
|
|
||||||
find: findReducer(state.find, action),
|
|
||||||
tab: tabReducer(state.tab, action), };
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,25 +1,10 @@
|
||||||
import addonReducer from './addon';
|
import { combineReducers } from 'redux';
|
||||||
import findReducer from './find';
|
import addon from './addon';
|
||||||
import settingReducer from './setting';
|
import find from './find';
|
||||||
import inputReducer from './input';
|
import setting from './setting';
|
||||||
import followControllerReducer from './follow-controller';
|
import input from './input';
|
||||||
|
import followController from './follow-controller';
|
||||||
|
|
||||||
// Make setting reducer instead of re-use
|
export default combineReducers({
|
||||||
const defaultState = {
|
addon, find, setting, input, followController,
|
||||||
addon: addonReducer(undefined, {}),
|
});
|
||||||
find: findReducer(undefined, {}),
|
|
||||||
setting: settingReducer(undefined, {}),
|
|
||||||
input: inputReducer(undefined, {}),
|
|
||||||
followController: followControllerReducer(undefined, {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function reducer(state = defaultState, action = {}) {
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
addon: addonReducer(state.addon, action),
|
|
||||||
find: findReducer(state.find, action),
|
|
||||||
setting: settingReducer(state.setting, action),
|
|
||||||
input: inputReducer(state.input, action),
|
|
||||||
followController: followControllerReducer(state.followController, action),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
Reference in a new issue