上一页 1 ··· 7 8 9 10 11
摘要: 示例1:useMounted export const useMounted = () => { const isMounted = useRef<boolean>(false); useEffect(() => { isMounted.current = true; return () => { 阅读全文
posted @ 2020-11-06 22:50 老胡Andy 阅读(801) 评论(0) 推荐(1)
摘要: useState & useEffect useState与useEffect经常一起被使用,用法简单,这里不多做介绍。以下一些概念需要搞清楚: 1)仅在函数组件的头部调用Hook。不要在循环体中、条件判断或嵌套方法中调用Hook。 https://reactjs.org/docs/hooks-ru 阅读全文
posted @ 2020-11-06 22:30 老胡Andy 阅读(238) 评论(0) 推荐(0)
摘要: 官网参考地址: https://reactrouter.com/web/example/basic 基础用法: import { BrowserRouter as Router, Switch, Route, Link } from "react-router-dom"; <Router> <div 阅读全文
posted @ 2020-11-06 08:21 老胡Andy 阅读(218) 评论(0) 推荐(0)
摘要: 安装: npm install axios --save 新建TUAPI.js import axios from 'axios'; export const TUAPI = axios.create({ baseURL: process.env.REACT_APP_BASE_URL, respon 阅读全文
posted @ 2020-11-03 21:40 老胡Andy 阅读(247) 评论(0) 推荐(0)
摘要: ExpressJS常用中间件: npm install cookie-parser --save npm install body-parser --save npm install compression --save npm install errorhandler --save npm ins 阅读全文
posted @ 2020-11-03 21:39 老胡Andy 阅读(352) 评论(0) 推荐(0)
摘要: react-app-rewired的作用是在不eject的情况下修改webpack配置 目标:修改build的output目录 1: npm install react-app-rewired --save-dev 2: 根目录下新建文件:config-overrides.js 3:添加以下配置 m 阅读全文
posted @ 2020-11-03 21:35 老胡Andy 阅读(5727) 评论(0) 推荐(0)
摘要: 使用--typescript参数新建React项目 create-react-app react-ts-demo --template typescript 新建Header.tsx文件,加入以下代码: import React, { FC } from 'react'; interface MyP 阅读全文
posted @ 2020-11-03 16:59 老胡Andy 阅读(1436) 评论(2) 推荐(1)
上一页 1 ··· 7 8 9 10 11