FortuneCookie
FortuneCookie

Reputation: 1865

react-native : How to store and get stored data simultaneously from redux

I am using redux to store data from an api and in the very next step i need to get the stored data.

  1. this.props.fetchdata(id) // initiates the action to call the api, stores the api response in store.

  2. this.props.details // gets the stored data from store

I need to invoke both the calls one after another in componentDidMount so that i have the data in store before 2 is called. How to implement that??

Upvotes: 0

Views: 41

Answers (1)

B. Mohammad
B. Mohammad

Reputation: 2464

You can try async await pattern:

async componentDidMount(){
  await this.props.fetchdata(id);
  this.props.details();

But i dont understand, if you have data from api, use it directly without waiting to store it in redux and then getting it back from store.

Upvotes: 1

Related Questions