React native 如何仅禁用react native上的setState消息警告

React native 如何仅禁用react native上的setState消息警告,react-native,components,warnings,setstate,React Native,Components,Warnings,Setstate,我想禁用setState消息警告 在布局图1上: 我的构造函数: constructor(props){ super(props); //Constructeur this.lestachesitemsRef=getDatabase().ref('n0rhl66bifuq3rejl6118k8ppo/lestaches'); this.lestachesitems=[]; this.state={ //Debutdustate lestachesSource:

我想禁用setState消息警告

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

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()
    {
    //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} />
this.setState({Nom:text})value={this.state.Nom}/>
this.setState({Prenom:text})值={this.state.Prenom}/>
this.verl2()}onLongPress={()=>this.infol2()}buttonStyle={styles.View}图标={{{{name:'squirrel',type:'octicon',buttonStyle:styles.View}/>
this.ajouter()}onLongPress={()=>this.infoajout()}buttonStyle={styles.View}图标={{{name:'squirrel',type:'octicon',buttonStyle:styles.View}/>
布局2与布局1相同。 谢谢大家!

警告 警告将以黄色背景显示在屏幕上。这些警报称为黄盒。单击警报以显示更多信息或解除警报。 与红盒一样,您可以使用console.warn()触发黄盒。 在开发过程中,可以使用控制台禁用黄盒。disableYellowBox=true。通过设置应忽略的前缀数组,可以通过编程方式忽略特定警告:console.ignoredYellowBox=['Warning:…'] 在CI/Xcode中,还可以通过设置IS_测试环境变量来禁用黄盒

警告 警告将以黄色背景显示在屏幕上。这些警报称为黄盒。单击警报以显示更多信息或解除警报。 与红盒一样,您可以使用console.warn()触发黄盒。 在开发过程中,可以使用控制台禁用黄盒。disableYellowBox=true
。通过设置应忽略的前缀数组,可以通过编程方式忽略特定警告:console.ignoredYellowBox=['Warning:…'] 在CI/Xcode中,还可以通过设置IS_测试环境变量来禁用黄盒


您可能不想禁用它,它看起来非常糟糕(我想是异步相关的)。介意分享代码以便我们能更好地帮助你吗?@FerranNegre我添加了代码谢谢@FerranNegre您可能不想禁用它,它看起来非常糟糕(我想是异步相关的)。介意分享代码以便我们能更好地帮助你吗?@FerranNegre我添加了代码谢谢@费兰格里