Question about getting data sheet items


#1

Hi,

I’m new to React Studio and still exploring. I learnt about APIs and data sheets and how to link them. I also learnt how to update an API when the app starts, by using the “Force loading when app starts” option, or by doing the following in a component’s componentWillMount -

this.props.appActions.loadData_jsonsrc1(this.props.appActions.dataSheets[‘data_today’], this.props.appActions.serviceOptions_data_today, false);

I learnt about this.props.appActions.getDataSheet and am using it to do some custom coding in the componentWillMount. The idea is that it’ll take data from one data sheet and stage it in another, which I use to populate a sub component.

I’m doing the following -

console.log(this.props.appActions.getDataSheet(‘data_today’));
console.log(this.props.appActions.getDataSheet(‘data_today’).items);

The problem is that these two are showing different values.

this.props.appActions.getDataSheet(‘data_today’) shows updated data from the API

this.props.appActions.getDataSheet(‘data_today’).items shows the default values from the first fetch I did when creating the data sheet.

So much so that the first one shows items -> 0th item having values as integers (from the API), while the second shows items as string (from the default values)

Can someone tell me what I’m doing wrong? I want to take the items, take the first row, and then save some values from it into another data sheet. But if calling the getDataSheet and calling it’s items separately will result in different values, how do I get the updated data?

Thanks a lot in advance!