摘要: 官网地址:https://styled-components.com/docs/basics 使用Styled Component的几大理由 1)Scoped Style(范围限定的样式) 不用担心引用的css文件被其他人修改 2)CSS in JS 可以在JS中使用component内部变量做条件 阅读全文
posted @ 2020-11-06 23:56 老胡Andy 阅读(869) 评论(0) 推荐(1) 编辑
摘要: 示例1:useMounted export const useMounted = () => { const isMounted = useRef<boolean>(false); useEffect(() => { isMounted.current = true; return () => { 阅读全文
posted @ 2020-11-06 22:50 老胡Andy 阅读(760) 评论(0) 推荐(1) 编辑
摘要: useState & useEffect useState与useEffect经常一起被使用,用法简单,这里不多做介绍。以下一些概念需要搞清楚: 1)仅在函数组件的头部调用Hook。不要在循环体中、条件判断或嵌套方法中调用Hook。 https://reactjs.org/docs/hooks-ru 阅读全文
posted @ 2020-11-06 22:30 老胡Andy 阅读(206) 评论(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 阅读(202) 评论(0) 推荐(0) 编辑