# react-redux-study **Repository Path**: yanweiling/react-redux-study ## Basic Information - **Project Name**: react-redux-study - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-11-30 - **Last Updated**: 2021-11-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 安装redux yarn add redux redux 并不是facebook出品的,react的出品方facebook 也出品了类似于redux的插件,就是react-redux ## redux中的action 默认只支持返回普通对象 plain object,如果要返回函数,则需要额外借助插件 yarn add redux-thunk ## 如果使用facebook发布的react-redux,需要安装react-redux yarn add react-redux 有三大元素 容器组件 ui组件 redux 而react-redux主要向容器组件提供connect,用于连接ui组件和redux ## 如果需要查看redux中的所有数据状态 1.则需要在chromie中安装插件redux_dev_tool工具 2.而且程序中,还需要安装额外安装一个库,否则插件不起作用 yarn add redux-devtools-extension 3.并且在redux的store组件中, 引入import {composeWithDevTools} from 'redux-devtools-extension'; 以如下方式导出store export default createStore(allReducers,composeWithDevTools()) 或者 export default createStore(allReducers,composeWithDevTools()) ## 发布上线,要将代码编译成js语法 npm run build --这句话就是执行的package.json中 "build": "react-scripts build" build结束以后,会生成build文件夹 ## 部署build后的项目 1.可以采用node进行部署 2.也可以全局安装serve库,这个库可以指定某个文件夹做为根目录,启动服务 npm i serve -g 假如当前目录下有个文件夹 : build 文件夹 ,如果以build文件夹作为根目录启动服务,则 serve build