How to disable only the setState message warning o

2019-08-03 06:38发布

I want to disable the setState message warning

enter image description here

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: '',}
    }

My function :

    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 : '' })   } 
}

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)});});
    }

My 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} />

The Layout2 the same thing as Layout1. Thank you !

1条回答
ゆ 、 Hurt°
2楼-- · 2019-08-03 07:36

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

查看更多
登录 后发表回答