reactjs - React Native: undefined is not an object (evaluating '_this.setState') -


i'm @ bit of loss why i'm getting error message in simulator code below. line # indicated in comment.

this.setstate seems in correct object format.

  fetchdata: function() {     fetch(apiurl)       .then((response) => response.json())       .then((responsedata) => {         this.collectresponses(responsedata);       })       .then((responseobject) => {         this.sortpredictions(responseobject);       })       .then((predictionsobj) => {         this.setstate({   // error here!           castroinktlm: predictionsobj['5728'],           churchinktlm: predictionsobj['5726'],           churchinj: predictionsobj['4006'],           churchinn: predictionsobj['4448'],           montgout: predictionsobj['6994'],           church37in: predictionsobj['7073'],           church37out: predictionsobj['5667'],           castro37out: predictionsobj['3325'],           castro33in: predictionsobj['3255'],           fetchtime: predictionsobj['fetchtime']         });       })       .done();   }, 

i have not done react-native yet, believe error seeing, due this not within function scope (the 1 receives predictionsobj) parameter

fetchdata: function() {     var self = this;     fetch(apiurl)       .then((response) => response.json())       .then((responsedata) => {         this.collectresponses(responsedata);       })       .then((responseobject) => {         this.sortpredictions(responseobject);       })       .then((predictionsobj) => {           self.setstate({              castroinktlm: predictionsobj['5728'],           churchinktlm: predictionsobj['5726'],           churchinj: predictionsobj['4006'],           churchinn: predictionsobj['4448'],           montgout: predictionsobj['6994'],           church37in: predictionsobj['7073'],           church37out: predictionsobj['5667'],           castro37out: predictionsobj['3325'],           castro33in: predictionsobj['3255'],           fetchtime: predictionsobj['fetchtime']         });       })       .done();   }, 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -