react-principal
Version:
A state management with react context for apps which using hooks.
15 lines • 530 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createReducer = void 0;
const persist_1 = require("./persist");
const createReducer = (handlers) => (state, action) => {
if (action.type === persist_1.INITIALIZE_STATE_FROM_STORAGE) {
return { ...state, ...action.payload };
}
if (!handlers.hasOwnProperty(action.type)) {
return state;
}
return handlers[action.type](state, action);
};
exports.createReducer = createReducer;
//# sourceMappingURL=reducer.js.map