Redux简介
使用Hook实现功能(不使用redux)
Redux三大核心概念➕ 完整版代码(未优化)
Redux异步action
react-redux库
react-redux数据共享
总结:
——合并reducers,单独写成一个文件
—— 继续简写:改变reducer命名
—— 由于键值同名,继续简写
—— store.js文件夹只需引用汇总后的reducer
—— 总结
开发者工具
一、在开发者工具中的扩展程序中安装Redux DevTools
开发者工具
二、之后在命令行中输入以下内容,安装对应的库
tnpm i redux-devtools-extension
三、在store.js中引入下载的库
/*
该文件专门用于暴露一个store对象,整个应用只有一个store对象
*/
// 引入createStore,专门用于创建redux中最为核心的store对象
import { createStore, applyMiddleware } from 'redux'
// 引入为Count组件服务的reducer
import CountReducer from './count_reducer'
// 引入redux-devtools-extension
import { composeWithDevTools } from 'redux-devtools-extension'
// 引入redux-thunk,用于支持异步action
import thunk from 'redux-thunk'
// 暴露store
export default createStore(
CountReducer,
composeWithDevTools(applyMiddleware(thunk))
// 如果没有异步,就写成这样
// composeWithDevTools()
)