如何在React Native上仅禁用setState消息警告 [英] How to disable only the setState message warning on react native

查看:117
本文介绍了如何在React Native上仅禁用setState消息警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要禁用setState消息警告

I want to disable the setState message warning

在布局1上:
我的构造函数:

On the layout 1 : My constructor :

constructor(props){
super(props);
//Constructeur

    this.lestachesitemsRef=getDatabase().ref('n0rhl66bifuq3rejl6118k8ppo/lestaches'); this.lestachesitems=[];
    this.state={
    //Debutdustate
    lestachesSource: new ListView.DataSource({rowHasChanged: (row1, row2)=>row1 !== row2}),
    Prenom: '',
    Nom: '',}
    }

我的函数:

    ajouter= () => {
 if( (this.state.Nom !== '') && (this.state.Prenom !== '')) { this.lestachesitemsRef.push({  Nom: this.state.Nom , Prenom: this.state.Prenom , });  this.setState({ Nom : '' }) , this.setState({ Prenom : '' })   } 
}

我的componentDidMount

My componentDidMount

 componentDidMount()
    {
    //DidMount
     this.lestachesitemsRef.on('child_added',   (dataSnapshot)=>{ this.lestachesitems.push({id: dataSnapshot.key,   text: dataSnapshot.val()}); this.setState({lestachesSource: this.state.lestachesSource.cloneWithRows(this.lestachesitems)}); });
      this.lestachesitemsRef.on('child_removed', (dataSnapshot)=>{ this.lestachesitems = this.lestachesitems.filter((x)=>x.id !== dataSnapshot.key);  this.setState({ lestachesSource: this.state.lestachesSource.cloneWithRows(this.lestachesitems)});});
    }

我的Vue:

<TextInput style={styles.Dtext} placeholder="Nom" onChangeText={(text) => this.setState({Nom: text})} value={this.state.Nom}/>

<TextInput style={styles.Dtext} placeholder="Prenom" onChangeText={(text) => this.setState({Prenom: text})} value={this.state.Prenom}/>

<Button title='Allerlayout2' onPress={() => this.verl2()} onLongPress={() => this.infol2()} buttonStyle={ styles.View } icon={{name: 'squirrel', type: 'octicon', buttonStyle: styles.View }}  />
<Button title='ajouter' onPress={() => this.ajouter()} onLongPress={() => this.infoajout()} buttonStyle={ styles.View } icon={{name: 'squirrel', type: 'octicon', buttonStyle: styles.View }}  />

<ListView dataSource={this.state.lestachesSource} renderRow={this.renderRowlestaches.bind(this)} enableEmptySections={true} />

Layout2与Layout1相同。
谢谢!

The Layout2 the same thing as Layout1. Thank you !

推荐答案

警告
警告将以黄色背景显示在屏幕上。这些警报称为YellowBoxes。单击警报以显示更多信息或将其消除。
与RedBox一样,您可以使用console.warn()触发YellowBox。可以在开发期间通过使用 console.disableYellowBox = true; 禁用
YellowBoxes。可以通过设置应忽略的前缀数组来以编程方式忽略特定的警告: console.ignoredYellowBox = ['Warning:...'];。
在CI / Xcode中,YellowBoxes可以也可以通过设置IS_TESTING环境变量来禁用它。

Warnings Warnings will be displayed on screen with a yellow background. These alerts are known as YellowBoxes. Click on the alerts to show more information or to dismiss them. As with a RedBox, you can use console.warn() to trigger a YellowBox. YellowBoxes can be disabled during development by using console.disableYellowBox = true;. Specific warnings can be ignored programmatically by setting an array of prefixes that should be ignored: console.ignoredYellowBox = ['Warning: ...'];. In CI/Xcode, YellowBoxes can also be disabled by setting the IS_TESTING environment variable.

http://facebook.github.io/react-native/docs/debugging.html#yellowbox-redbox

这篇关于如何在React Native上仅禁用setState消息警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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