I have a state called isTeaxher in my react.js application.
I receive data from server and then set it's value :
if(JSON.parse(this.responseText).isTeacher===true || JSON.parse(this.responseText).isTeacher==='true' || JSON.parse(this.responseText).isTeacher==="true")
that.setState({'isTeacher':'on'});
else
that.setState({'isTeacher':'off'});
console.log(that.state.isTeacher);
console.log() shows value is being changed.
I do this in my componentWillMount function, but the problem is when I render this the checkbox is always unchecked.
Maybe because the is difference between 'on' and "on" and on.
How can I resolve this ?
Aucun commentaire:
Enregistrer un commentaire