# react-staging
**Repository Path**: daimananshen/react-staging
## Basic Information
- **Project Name**: react-staging
- **Description**: React基础知识
- **Primary Language**: Unknown
- **License**: MulanPSL-2.0
- **Default Branch**: dev
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 1
- **Forks**: 0
- **Created**: 2021-08-02
- **Last Updated**: 2021-09-06
## Categories & Tags
**Categories**: Uncategorized
**Tags**: React, React基础笔记
## README
# Getting Started with Create React App
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.\
You will also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
### Analyzing the Bundle Size
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
### Making a Progressive Web App
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
### Advanced Configuration
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
### Deployment
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
### `npm run build` fails to minify
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
FeHelper
react-devtools
react使用proxy代理配置
src文件夹下面setupProxy.js,引用http-proxy-middleware
const proxy = require('http-proxy-middleware')
module.exports = function (app) {
app.use("/api", //遇到/api前缀,才会触发代理请求
proxy({
target: 'http://localhost:5000', //请求转发给谁
changeOrigin: true, //控制header中请求头中HOST字段的值
pathRewrite: { // 重新请求路径
"^/api": ""
}
})
)
}
--------------------------------------------------------
npm add pubsub-js 或 yarn add pubsub-js
npm add react-router-dom 或 yarn add react-router-dom
---------------------------------------------------------
1、写法不同
一般组件:
路由组件:
2、放置位置不同
一般组件: components
路由组件: pages
3、收到的props不同
一般组件: 组件标签传递什么,就接收什么
路由组件: 接收到3个固定的属性 history location match
--------------------------------------------------------
About
如果点击高亮的样式叫active,可以不写activeClassName="highlight"
1、底层原理不一样
(1) BrowserRouter 使用的是H5 API,不兼容IE9以下IE版本
(2) HashRouter 使用的是URL的哈希值
2、path表示形式不一样
(1) BrowserRouter 路径中没有#,例如 http://localhost:3000/about
(2) HashRouter 路径中有#,例如 http://localhost:3000/#/about
3、刷新后对路由参数state的影响
(1) BrowserRouter 没有影响,因为state保存在history中
(2) HashRouter 刷新后会导致路由state参数丢失
4、HashRouter有的时候可以解决路径出错的问题
npm add antd 或 yarn add antd
npm add redux 或 yarn add redux
npm add redux-thunk 或 yarn add redux-thunk
npm add react-redux 或 yarn add react-redux