【问题标题】:Hide All Warnings in Terminal of Visual Studio Code for React-Native Code为 React-Native 代码隐藏 Visual Studio 代码终端中的所有警告
【发布时间】:2021-08-04 12:58:44
【问题描述】:

我正试图在 Visual Studio Code 的终端中禁用我的 react-native 应用程序中的所有黄色警告。我知道 LogBox,但这似乎适用于应用程序本身,而不是 IDE。现在不仅黄色警告妨碍了我试图登录到控制台的内容,而且同样的警告正在多次打印到终端。如何在 Visual Studio Code 的终端中简单地禁用来自 react-native 的警告打印?

以下是在 VSC 终端中多次打印的警告示例。我只是想完全隐藏这些。

It appears that you are using old version of react-navigation library. Please update @react-navigation/bottom-tabs, @react-navigation/stack and @react-navigation/drawer to version 5.10.0 or above to take full advantage of new functionality added to react-native-screens
at node_modules/react-native-screens/src/index.native.tsx:141:8 in Screen#render
at [native code]:null in performSyncWorkOnRoot
at [native code]:null in callFunctionReturnFlushedQueue

It appears that you are using old version of react-navigation library. Please update @react-navigation/bottom-tabs, @react-navigation/stack and @react-navigation/drawer to version 5.10.0 or above to take full advantage of new functionality added to react-native-screens
at node_modules/react-native-screens/src/index.native.tsx:141:8 in Screen#render
at [native code]:null in performSyncWorkOnRoot
at [native code]:null in callFunctionReturnFlushedQueue

【问题讨论】:

    标签: reactjs react-native visual-studio-code


    【解决方案1】:

    在你的 App.js 中试试这个:

    import { LogBox } from "react-native";
            
    export default function App() {
        LogBox.ignoreLogs([
            "It appears that you are using old version of react-navigation library",
          ]);
          // ... the rest of your code ...
    }
    

    注意:使用以下方法,您应该可以忽略所有日志,但由于某种原因,这对我不起作用,但您应该尝试一下:

      LogBox.ignoreAllLogs(true);
    

    来源:SDK 40 react-native-screens warning if using react-navigation v4

    另请阅读:YellowBox has been replaced with LogBox. Please call LogBox.ignoreLogs() instead.

    【讨论】:

    • 谢谢。那行得通。奇怪的是ignoreAllLogs 不起作用。
    • 另外,奇怪的是,这适用于某些消息,但不是全部。我包含在数组中的一些人不会被捕获,而其他人会。
    猜你喜欢
    • 2019-04-03
    • 1970-01-01
    • 2022-11-24
    • 1970-01-01
    • 1970-01-01
    • 2017-04-11
    • 2014-01-06
    • 1970-01-01
    • 2021-04-10
    相关资源
    最近更新 更多