尝试禁用react_devtools_backend.js nextjs
最近,我添加了react devtools后端
扩展程序,我注意到它会导致2个附加组件渲染(我正在使用nextjs
框架),这并不是什么问题在开发中,当发布时,这确实会达到网站的性能,并且我正在尝试将其禁用,并且我已经在_document.js
文件中添加了以下代码:
import { Html, Head, Main, NextScript } from "next/document";
import Script from "next/script";
export default function Document() {
return (
<Html lang="en-US">
<Head />
<body>
<Main />
<NextScript />
<Script
strategy="beforeInteractive"
dangerouslySetInnerHTML={{
__html: `if(typeof window.__REACT_DEVTOOLS_GLOBAL_HOOK__ === 'object'){ __REACT_DEVTOOLS_GLOBAL_HOOK__.inject = function() {}; }`,
}}
/>
</body>
</Html>
);
}
但是没有更改任何事物。
recently I've added the react devtools backend
extension which I noticed is causing 2 additional component renders (I'm using Nextjs
framework) which isn't so much of a problem in development however when published this would really hit the websites performance and I'm trying to disable it, and to do so I've adding the following code in _document.js
file:
import { Html, Head, Main, NextScript } from "next/document";
import Script from "next/script";
export default function Document() {
return (
<Html lang="en-US">
<Head />
<body>
<Main />
<NextScript />
<Script
strategy="beforeInteractive"
dangerouslySetInnerHTML={{
__html: `if(typeof window.__REACT_DEVTOOLS_GLOBAL_HOOK__ === 'object'){ __REACT_DEVTOOLS_GLOBAL_HOOK__.inject = function() {}; }`,
}}
/>
</body>
</Html>
);
}
But hasn't changed anything.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论