摆脱“远程调试器在后台选项卡中";React Native 中的警告 [英] Get rid of "Remote debugger is in a background tab" warning in React Native

查看:23
本文介绍了摆脱“远程调试器在后台选项卡中";React Native 中的警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始了一个新的 React Native 项目,但不断收到以下警告:

<块引用>

远程调试器位于后台选项卡中,这可能会导致应用运行缓慢.通过将选项卡置于前台(或在单独的窗口中打开它)来解决此问题.

这有点烦人,所以我想知道如何摆脱它?我正在 Chrome 中运行调试器,并将其移至单独的窗口,但没有帮助.

解决方案

如果您在调试器窗口中有 Maintain Priority 复选框,请在跳转到以下任何解决方案之前尝试启用它.

要消除整个项目中的警告,请将以下内容添加到最外层 Javascript 文件(大部分时间是 React Native 的 index.js)

对于本机 v0.63+:

使用LogBox:https://reactnative.dev/docs/debugging#logbox

LogBox.ignoreLogs(['远程调试器']);

对于 react-native v0.57 - v0.62:

import { YellowBox } from 'react-native';YellowBox.ignoreWarnings(['远程调试器']);

参考 React Native 官方文档:

https://facebook.github.io/react-native/docs/调试.html

react-native v0.56 或以下:

尽早在代码中添加以下内容:

console.ignoredYellowBox = ['远程调试器'];

容易、简单且特定于该错误.为我工作.可以替换任何你想要的文字.

I've started a new React Native project and I keep getting the following warning:

Remote debugger is in a background tab which may cause apps to perform slowly. Fix this by foregrounding the tab (or opening it in a separate window).

It's a bit annoying so I wanna know how I can get rid of it? I'm running the debugger in Chrome and I moved it to a seperate window but it did not help.

解决方案

If you have the Maintain Priority checkbox in the debugger window, try enabling it before you jump to any of the solutions below.

To get rid of the warning in your whole project add the following to your outermost Javascript file (most of the time that's index.js for React Native)

for react-native v0.63+:

Use LogBox: https://reactnative.dev/docs/debugging#logbox

LogBox.ignoreLogs(['Remote debugger']);

for react-native v0.57 - v0.62:

import { YellowBox } from 'react-native';
YellowBox.ignoreWarnings(['Remote debugger']);

Reference this from the official React Native docs:

https://facebook.github.io/react-native/docs/debugging.html

react-native v0.56 or below:

Add the following early on in your code:

console.ignoredYellowBox = ['Remote debugger'];

Easy, simple and specific to that error. Works for me. Can substitute for any text you want.

这篇关于摆脱“远程调试器在后台选项卡中";React Native 中的警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆