跳到主要内容

bug 回忆录

Prettier 格式化未生效

Support .prettierrc.js when type module is used in package.json #12701

将 .prettierrc.js 改为 .prettierrc.cjs 即可

ESLint 运行报错

javascript - Error while loading rule '@typescript-eslint/dot-notation' - Stack Overflow

React

React 18 会自动导入

reactjs - 使用 JSX react/react-in-jsx-scope 时,'React' 必须在范围内吗? - 堆栈溢出 (stackoverflow.com)

vite 打包组件库时出现了无法从 node_modules 的包中推断类型的错误

vite-plugin-dts/README.zh-CN.md at main · qmhc/vite-plugin-dts (github.com)

1673884476806

CI 错误 remote: Permission to git denied to github-actions [bot]

remote: Permission to git denied to github-actions[bot]. #96

换成 git token 或提升权限

Cannot read properties of null (reading 'useCallback')

react_devtools_backend.js:4012 Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:

  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app

react.development.js?6237:1646 Uncaught TypeError: Cannot read properties of null (reading 'useCallback') at useCallback (react.development.js?6237:1646:1) at Icon (dance-ui.es.js?b4ad:953:1)

pnpm upgrade react@^17.0.2 -w
pnpm upgrade react-dom@^17.0.2 -w

ReferenceError: window is not defined

文档站打包时报错:

[ERROR] Docusaurus server-side rendering could not render static page with path /docs/components/Icon.

ReferenceError: window is not defined
ReferenceError: Cannot access 'IconNames' before initialization
[ERROR] Unable to build website for locale zh-Hans.
[ERROR] Error: Failed to compile with errors.

原因是直接引入的 iconfont.js 中使用了 window,改为挂载后再使用

// ...
useMount(() => {
import('./script/iconfont.js' as any)
console.log('mounted')
})

Jest 引入 loadsh-es 时出错

1676813096781