score:0

if your comparison is between title.rendered not this.state.title.rendered and this.state.data.title.rendered then i think the reason is that the setstate is asynchronous and maybe before the value of data is put on the state you are calling it already in some point inside render hence it's not yet available but as for title.rendered it's just a constant that is sitting there and waiting to be used. you can how ever make sure this works by doing a check ie if you did not expect just an answer then you can do something like

this.state.data && this.state.data.title.rendered

score:2

each setstate call results in a different state, you may want to use destructuring assignment on responsejson.data like so: this.setstate({ ...responsejson.data });

// each value reprensets an entry
this.setstate({ title, fimg_url, content });
// state = { title: 'value', fimg_url: 'value', content: 'value' };


// responsejson is a value of `data` key
this.setstate({ data: responsejson });
// state = { data: { title: 'value', fimg_url: 'value', content: 'value' }

// you may want to use:
this.setstate({ ...responsejson.data });

Related Query

More Query from same tag