忽略 componentWillMount 和 componentWillReceiveProps 警告消息 [英] Ignore componentWillMount and componentWillReceiveProps warning messages

查看:44
本文介绍了忽略 componentWillMount 和 componentWillReceiveProps 警告消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使我没有在代码中使用这些函数,这些烦人的消息也会一直出现.问题是我的一些依赖项使用它们.它们阻塞了模拟器和调试器的屏幕.我必须一直关闭它们,而这些消息与我的开发无关.我怎么能忽略它们?

These annoying messages appear all the time even I don't use these functions in my code. The problem is that some of my dependencies use them. They block the screen of the simulator and the debugger. I have to close them all the time and these messages are not relevant for my development. How can I ignore them?

推荐答案

忽略特定的 YellowBox 消息:

To ignore specific YellowBox messages:

import { YellowBox } from 'react-native';

class App extends Component {

  constructor(props) {
    super(props);

    YellowBox.ignoreWarnings([
      'Warning: componentWillMount is deprecated',
      'Warning: componentWillReceiveProps is deprecated',
    ]);

  }
...

更新:正如@Auticcat 指出的,这仅适用于模拟器.

UPDATE: As @Auticcat points out, this only applies to the simulator.

这篇关于忽略 componentWillMount 和 componentWillReceiveProps 警告消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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