【发布时间】:2022-06-10 22:16:08
【问题描述】:
世博版本:45 使用堆栈导航和本机基础。 我正在使用道具,但我收到了这个警告。 为什么我会收到此警告?
【问题讨论】:
标签: javascript react-native expo react-navigation native-base
世博版本:45 使用堆栈导航和本机基础。 我正在使用道具,但我收到了这个警告。 为什么我会收到此警告?
【问题讨论】:
标签: javascript react-native expo react-navigation native-base
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",
])
【讨论】:
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";
【讨论】: