score:0

Accepted answer

the appdata is set asynchronously and may have not been set while you are trying to log in the render method. either log the response in the then method of getappdata or in the render method with console.log(value && value["operating_cities"]);

you can either set an empty object in your initial state

componentdidmount(){

client.getappdata().then(res=>{
    this.setstate({
        initiated: true,
        appdata: res // this is where you are setting the data and this is asynchronous
    });
})

this.setstate({
    // visiblesidebar: window.innerwidth > 720,
    innerwidth: window.innerwidth,
    appdata: {} //option 1: you can initialize here with an empty object and you don't have to add checks in your render method
})

}

or you need to handle it in the render method

const value = this.state.appdata;
if(value){ //option 2: check if value has been set, default it was undefined
 // do your rendering 
} else {
 // you can display a loading spinner or something...
}

Related Query

More Query from same tag