2.0.2 • Published 5 years ago

@guiguzixl/redux-add-reducer v2.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
5 years ago

redux-add-reducer

Add dynamically reducer.

install

npm install --save @guiguzixl/redux-add-reducer

or

yarn add @guiguzixl/redux-add-reducer

example

用法和 redux 几乎一样,区别在于创建 store 的时候不用再传入 reducer,而是通过 store.addReducer 动态的添加 reducer。addReducer 接受一个对象为参数,和 combineReducers 一致,另外 preloadedState 必须为对象。

import { createStore } from '@guiguzixl/redux-add-reducer'
const store = createStore(preloadedState, enhancer)

const addReducerShape = {
  reducerKey: reducerFunction,
}
store.addReducer(addReducerShape)