03 2022 档案

摘要:npm install -S @braintree/sanitize-url将url处理成'about:blank' 阅读全文
posted @ 2022-03-15 10:44 古德拉克 阅读(80) 评论(0) 推荐(0) 编辑
摘要:import React from 'react' import { useSelector, useDispatch } from 'react-redux' export function Counter() { // 从 state 中获取当前的计数值 const count = useSel 阅读全文
posted @ 2022-03-08 17:41 古德拉克 阅读(94) 评论(0) 推荐(0) 编辑
摘要:自定义 Hooks 典型的四个使用场景:1.抽取业务逻辑;2.封装通用逻辑;3.监听浏览器状态;4.拆分复杂组件。 import React, { useEffect, useCallback, useMemo, useState } from "react"; import { Select, T 阅读全文
posted @ 2022-03-08 17:08 古德拉克 阅读(34) 评论(0) 推荐(0) 编辑
摘要:事实上,在处理这类请求的时候,模式都是类似的,通常都会遵循下面步骤: 1.创建 data,loading,error 这 3 个 state; 2.请求发出后,设置 loading state 为 true; 3.请求成功后,将返回的数据放到某个 state 中,并将 loading state 设 阅读全文
posted @ 2022-03-08 16:34 古德拉克 阅读(32) 评论(0) 推荐(0) 编辑
摘要:const themes = { light: { foreground: "#000000", background: "#eeeeee" }, dark: { foreground: "#ffffff", background: "#222222" } }; // 创建一个 Theme 的 Co 阅读全文
posted @ 2022-03-08 16:01 古德拉克 阅读(321) 评论(0) 推荐(0) 编辑
摘要:useEffect 让我们能够在下面四种时机去执行一个回调函数产生副作用: 1.每次 render 后执行:不提供第二个依赖项参数。比如useEffect(() => {})。 2.仅第一次 render 后执行:提供一个空数组作为依赖项。比如useEffect(() => {}, [])。 3.第 阅读全文
posted @ 2022-03-08 14:53 古德拉克 阅读(365) 评论(0) 推荐(0) 编辑
摘要:<BrowserRouter> <Routes> <Route path="/" element={<Home />} /> <Route path="/about" element={<About />} /> <Route path="posts" element={<Posts />}> <R 阅读全文
posted @ 2022-03-03 19:59 古德拉克 阅读(85) 评论(0) 推荐(0) 编辑
摘要:git commit 的时候出现上述问题,删除掉了根目录下面的pre-commit文件和一个下划线目录就可以了,具体原因不知道。 阅读全文
posted @ 2022-03-02 17:30 古德拉克 阅读(58) 评论(0) 推荐(0) 编辑
摘要:window.localStorage[key] !== void 0; 猛然间看到了void 0,查阅后得知void 0 返回undefined,那为什么不写window.localStorage[key] !== undefined;呢? 因为 undefined在局部作用域可以被重写,但是全局 阅读全文
posted @ 2022-03-02 08:54 古德拉克 阅读(50) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示