【问题标题】:WARN ViewPropTypes will be removed from React Native. Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types'WARN ViewPropTypes 将从 React Native 中移除。迁移到从 'deprecated-react-native-prop-types' 导出的 ViewPropTypes
【发布时间】:2022-06-10 22:16:08
【问题描述】:

世博版本:45 使用堆栈导航和本机基础。 我正在使用道具,但我收到了这个警告。 为什么我会收到此警告?

【问题讨论】:

    标签: javascript react-native expo react-navigation native-base


    【解决方案1】:

    Native Base 尚未更新其源代码以包含对deprecated-react-native-prop-types 的迁移。你可以在这里阅读更多关于它的信息https://github.com/facebook/react-native/issues/33557

    您可以在您的应用(可能是 App.js)的开头添加以下 sn-p 以暂时抑制警告。

    import {LogBox} from "react-native";
    
    LogBox.ignoreLogs([
    "ViewPropTypes will be removed",
    "ColorPropType will be removed",
    ])
    

    【讨论】:

      【解决方案2】:

      临时解决办法。

      ignoreWarnings.js

      import { LogBox } from "react-native";
      
      if (__DEV__) {
        const ignoreWarns = [
          "EventEmitter.removeListener",
          "[fuego-swr-keys-from-collection-path]",
          "Setting a timer for a long period of time",
          "ViewPropTypes will be removed from React Native",
          "AsyncStorage has been extracted from react-native",
          "exported from 'deprecated-react-native-prop-types'.",
          "Non-serializable values were found in the navigation state.",
          "VirtualizedLists should never be nested inside plain ScrollViews",
        ];
      
        const warn = console.warn;
        console.warn = (...arg) => {
          for (const warning of ignoreWarns) {
            if (arg[0].startsWith(warning)) {
              return;
            }
          }
          warn(...arg);
        };
      
        LogBox.ignoreLogs(ignoreWarns);
      }
      

      App.js

      // import at the very top of everything.
      import "../ignoreWarnings";
      

      【讨论】:

        猜你喜欢
        • 2022-06-10
        • 2022-08-24
        • 2023-01-25
        • 2022-09-25
        • 2018-11-24
        • 1970-01-01
        • 2022-01-12
        • 2022-09-30
        • 1970-01-01
        相关资源
        最近更新 更多