【问题标题】:react-native : How to store and get stored data simultaneously from reduxreact-native : 如何同时从 redux 存储和获取存储的数据
【发布时间】:2020-01-20 15:37:49
【问题描述】:

我正在使用 redux 存储来自 api 的数据,下一步我需要获取存储的数据。

  1. this.props.fetchdata(id) //发起调用api的动作,将api响应存入store。

  2. this.props.details // 从 store 中获取存储的数据

我需要在 componentDidMount 中依次调用这两个调用,以便在调用 2 之前存储数据。如何实施?

【问题讨论】:

    标签: react-native react-redux redux-saga


    【解决方案1】:

    你可以试试asyncawait模式:

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

    但我不明白,如果你有来自 api 的数据,直接使用它,而无需等待将其存储在 redux 中然后从存储中取回。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-26
      • 1970-01-01
      • 2018-09-29
      • 1970-01-01
      相关资源
      最近更新 更多