一、request to https://registry.npm.taobao.org/create-react-app failed, reason: certificate has expired
使用npx create-react-app xxx时报错,这是由于我们的镜像问题
重新设置镜像
1.npm config set registry https://registry.npmmirror.com/
2.npm config get registry (查看是否成功)
3.npx create-react-app xxx
tips:(npx comes with npm 5.2+ and higher)
国内镜像最新地址参考网址:https://npmmirror.com/
二、name can no longer contain capital letters
使用npx create-react-app xxx时报错,这是很简单的问题,创建的React项目名称不要包含大写字母,这是因为npm的命名限制
三、img elements must have an alt prop, either with meaningful text, or an empty string for decorative images.
这个的意思是img标签添加一个alt属性是一个非常好的习惯,防止任何错误引起的图片问题,Stack Overflow也有讨论到
四、React18 componentDidMount 重复执行两次的问题
将 index.tsx
或者 index.js
文件里的 React.StrictMode
高阶组件包围去掉即可
修改前
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
修改后
root.render(
//<React.StrictMode>
<App />
//</React.StrictMode>
);