jfreact-redux

jfreact-redux

推荐:jfreact-redux

它是一个以vuex模块文件编写方式的redux封装库,你可以以vuex的思维方式去构建你的redux,效率方面也不需要当心,这是一个简单的转换。

优势:

如果你有使用vuex,会发现,它的结构很容易理解,很清晰,action, mutation, state。看它按模块划分后得数据格式:

{
  namespaced: true,
  state: {},
  mutation: {},
  action: {}
}

然后再看看react redux:

const store = createStore(reducer, initialState, batch().enhancer)
store.dispatch(createAction({ type: 'INCREMENT' }, { type: 'INCREMENT' }))

dispatch中传一个action,然后传type去通知reducer,玩vue的小伙伴是不是感觉根本不知道我在说什么,会react也不屑于看,

但是现实告诉你,公司招了个react的架构师,后面招得人就得会react,用jfreact-redux就可以让事情变得很简单(你来吧,是个前端都可以会)

具体使用,请看:https://www.npmjs.com/package/jfreact-redux