React native不要调用PropTypes Warnings
React native don't Call PropTypes Warnings?
谁能建议如何删除第三方警告?https://facebook.github.io/react/warnings/dont-call-proptypes.html
我不知道如何实现以及在哪里放置官方文档中提到的代码。它们从react-bootstrap
中获取代码export default function deprecated(propType, explanation) {
return function validate(props, propName, componentName) {
if (props[propName] != null) {
const message = `"${propName}" property of
"${componentName}" has been deprecated.'n${explanation}`;
if (!warned[message]) {
warning(false, message);
warned[message] = true;
}
}
return propType(props, propName, componentName);
};
}
请写一步一步解决第三方警告。
谢谢
您可以显示您的代码片段在哪里处理Proptypes?也许一些库或甚至react native代码触发了这些react警告,所以检查你的react native版本是否与react正确的版本匹配。
如果你想阻止"Yellow Box"调试助手出现,你可以使用console.ignoredYellowBox
属性将不应该显示的前缀列入白名单:
const existingIgnoreList = console.ignoredYellowBox;
const prefixesToIgnore = [
'Warning: "foo" property of "Bar"'
];
console.ignoredYellowBox = existingIgnoreList
? existingIgnoreList.concat(prefixesToIgnore)
: prefixesToIgnore;
基于注释编辑:如果您想实际抑制控制台。错误信息,没有官方和合法的方法来做到这一点。
可以做的是猴子补丁console.error
方法并过滤掉特定的消息。修补程序需要在您的应用程序代码被评估之后,但在挂载有问题的组件之前进行。
一个好的地方将是在根组件的componentWillMount
处理程序:
componentWillMount() {
console.__error = console.error;
console.error = function overrideConsoleError(...args) {
if (!typeof args[0] === 'string' || !args[0].startsWith('Warning: "foo" property of "Bar"')) {
console.__error(...args);
}
};
}
但是请,请不要这样做。这真是个坏主意
相关文章:
- Reacts 'propTypes' 和 'defaultProps' 应该与 Flowtype 结合使用,还是 Flo
- Netbeans javascript warnings for "==", "!=&qu
- propTypes isRequired约束错误地引导react中的行为
- 如何验证ReactJS中组件的PropTypes是相互包含的?
- ReactJS组件PropTypes——用一组参数指定一个函数类型
- 使propTypes成为强制性的,并且有stattypes
- React Bootstrap和React.PropTypes验证功能
- 在react-js中使用immutable-js时使用PropTypes
- static propTypes Vs React.PropTypes
- 特定组件的PropTypes
- React -测试组件propTypes -预期失败
- React native不要调用PropTypes Warnings
- 手动调用React.PropTypes验证函数React-Materialize
- 有没有可能“松散地”使用React.PropTypes.shape定义一个对象
- ReactJS-添加/修改无状态功能组件的propTypes的多种方法
- React Enzyme Type错误:无法读取属性'propTypes'的未定义
- 我们是否需要导入 React 或只有 {Component, PropTypes} 就可以了
- 跨共享组件的React js和PropTypes重复