react-redux

it2026-02-16  7

react-redux

<Provider store>使组件能够使用connect()方法连接到Redux store。connect()方法中常见的两个参数mapStateToProps和mapDispatchToProps。 mapStateToProps允许将store中的state数据作为props绑定到组件上面。mapDispatchToProps允许将action作为props绑定到组件上面 其他的流程和redux更新状态的方式差不多 创建一个store存放state创建reducer接受初始state和自定义的action来返回新的state通过store.dispatch(action)来触发状态的改变
最新回复(0)