How to disable only the setState message warning on react native

你离开我真会死。 提交于 2019-12-24 07:18:27

问题


I want to disable the setState message warning

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:


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



来源:https://stackoverflow.com/questions/43608401/how-to-disable-only-the-setstate-message-warning-on-react-native

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!