- buggy: adj. 多虫的(有bug的)。eg: This is buggy code. This function is buggy.
- code motion。eg: 可以使用在代码优化中的 commit message 中
- pair: n. 一对,一双。eg:常用在成对出现的变量命名中
- allowList、denyList
- source(源)、destination(目的)
import React from 'react'; | |
import { Button, DatePicker, Form, Input } from 'antd'; | |
import moment from 'moment'; | |
const DemoPage: React.FC = () => { | |
const [form] = Form.useForm(); | |
const handleOk = (vals: any) => { | |
console.log(vals); | |
}; | |
return ( |
import { useEffect, useRef, useState } from 'react'; | |
// 解决“受控组件*******”报错 | |
function fixControlledValue(value: string) { | |
if (typeof value === 'undefined' || value === null) return ''; | |
return value; | |
} | |
interface InputProps { | |
/** 不受控 */ |
TLDR: Use for...of
instead of forEach
in asynchronous code.
Array.prototype.forEach
is not designed for asynchronous code. (It was not suitable for promises, and it is not suitable for async-await.)
For example, the following forEach loop might not do what it appears to do:
// 反转对象 key value | |
type ReverseObject<T extends Record<keyof T, keyof any>> = { | |
[P in T[keyof T]]: { | |
[K in keyof T]: T[K] extends P ? K : never; | |
}[keyof T]; | |
}; |
"Function Component": { | |
"prefix": "fc", | |
"body": [ | |
"interface $1Props {", | |
"\t$2", | |
"}", | |
" ", | |
"const $1: React.FC<$1Props> = (props) => {", | |
"\tconst {} = props;", | |
"\treturn ($0);", |
{url:'stun:stun01.sipphone.com'}, | |
{url:'stun:stun.ekiga.net'}, | |
{url:'stun:stun.fwdnet.net'}, | |
{url:'stun:stun.ideasip.com'}, | |
{url:'stun:stun.iptel.org'}, | |
{url:'stun:stun.rixtelecom.se'}, | |
{url:'stun:stun.schlund.de'}, | |
{url:'stun:stun.l.google.com:19302'}, | |
{url:'stun:stun1.l.google.com:19302'}, | |
{url:'stun:stun2.l.google.com:19302'}, |
import { renderHook } from '@testing-library/react'; | |
import { afterEach, beforeEach, describe, expect, it, vi, expectTypeOf } from 'vitest'; | |
import { useUaParser } from '../src'; | |
describe('useUaParser', () => { | |
const userAgent = | |
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.123 Safari/537.36'; | |
beforeEach(() => { | |
const originalNavigator = { ...window.navigator }; | |
vi.spyOn(window, 'navigator', 'get').mockImplementation(() => ({ |