mercredi 15 novembre 2017

I want to use react state value, how should i?

export default class App extends React.Component {
  constructor(props){
    super(props);
    this.state =  {
      createId: 'create ID here!',
      createPw: 'create Pw here',
      inputId: 'input Id',
      inputPw: 'input Pw',
      sentence: '',
      kev : false
    }
  }


  _onPressButton(){
    if(this.state.kev)
     Alert.alert('You tapped the button!');
  }

i want to use kev value, when it is true then alert and if it's false then not.

but i wonder why i got error 'undefined is not an object(evaluating 'this.state.kev')'

can anyone explain how should I call state value kev and why that error message occurs.

thanks!

Aucun commentaire:

Enregistrer un commentaire