react-redux store

1. 在多个容器组件使用redux时, 多个组件都需要共享redux里的数据时,就需要将多个容器组件合并起来, 用于合并多个组件的插件 combineReducers
import { createStore,combineReducers, applyMiddleware } from 'redux'
const allReducers = combineReducers({
'自定义键名': <A/>,
'自定义键名': <B/>
})
export default createStore(allReducers, applyMiddleware(thunk))
2. 在组件中使用dispatch 分发方法, 到action, 然后action 去 reducer处理数据
本文介绍了如何在React应用中使用combineReducers合并多个容器组件,并阐述了dispatch机制如何将组件操作转化为action,以便在reducer中处理数据。
1328

被折叠的 条评论
为什么被折叠?



