Use combineReducers

jh-changes
Shin'ya Ueoka 6 years ago
parent 37840c2abb
commit b69cc04856
  1. 23
      src/background/reducers/index.js
  2. 33
      src/content/reducers/index.js

@ -1,17 +1,8 @@
import settingReducer from './setting';
import findReducer from './find';
import tabReducer from './tab';
import { combineReducers } from 'redux';
import setting from './setting';
import find from './find';
import tab from './tab';
// Make setting reducer instead of re-use
const defaultState = {
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), };
}
export default combineReducers({
setting, find, tab,
});

@ -1,25 +1,10 @@
import addonReducer from './addon';
import findReducer from './find';
import settingReducer from './setting';
import inputReducer from './input';
import followControllerReducer from './follow-controller';
import { combineReducers } from 'redux';
import addon from './addon';
import find from './find';
import setting from './setting';
import input from './input';
import followController from './follow-controller';
// Make setting reducer instead of re-use
const defaultState = {
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),
};
}
export default combineReducers({
addon, find, setting, input, followController,
});