英语
What hell is it, exactly? 这到底是什么
In short term 从短期来看
potential problems 潜在问题
dive into the details of what strict mode is 深入了解...的细节
a set of development tools 一套开发工具
turn on a bunch of extra checks👀 and warnings 开启一堆额外的检查和提醒
Deprecated or unsafe lifecycle methods 废弃的不安全的生命周期方法
Unsafe use of certain built in functions 某些内置函数的不安全使用
Duplicate keys in lists 重复
be difficult to track down 很难追查
taking advantage of 利用
your support is greatly appreciated 非常感激您的支持
文章
是什么
strict mode是一套帮助开发者检查潜在问题的工具,如果开启后,他将会检查:
- Components with side effects
- Deprecated or unsafe lifecycle methods
- Unsafe use of certain built in functions
- Duplicate keys in lists
使用
Enable
import {StrictMode} from 'react';
function App() {
return (
<>
<Header />
<StrictMode>
<main>
<Sidebar />
<Content />
</main>
</StrictMode>
<Footer />
</>
);
}
补充
- 额外的检查会让你开发时变慢但Strict mode对生产环境没有任何影响
- strict mode可以让你保持最新的最佳实践,通过提示获取react最新的改动
- 还有一些举例可以看原文