【问题标题】:React Apollo multiple refetches not workingReact Apollo 多次重新获取不起作用
【发布时间】:2020-02-04 15:08:48
【问题描述】:

我正在尝试进行这三个重新获取,但只有一个有效。我不知道是什么问题。

onChangeText={(text) => {
  this.props.searchEvent.refetch({ term: text })
  this.props.searchUser.refetch({ name: text })
  this.props.searchLocation.refetch({ location: text })
  this.setState({ searchTerm: text })
}}

【问题讨论】:

  • 请编辑您的问题以提供更多详细信息。哪两个查询没有被重新获取?你怎么知道它们没有被重新获取——你有没有在网络选项卡中查看请求是否被触发?控制台中是否显示任何错误?看看你的更多代码也很好,包括查询本身以及你如何使用 react-apollo 组件。

标签: reactjs react-native apollo react-apollo


【解决方案1】:

我通过使回调函数异步解决了这个问题。

onChangeText={async (text) => {

                            await this.props.searchUser.refetch({ name: text })
                            await this.props.searchEvent.refetch({ term: text })
                            await this.setState({ searchTerm: text })
                            await this.props.searchLocation.refetch({ location: text })

                        }}

【讨论】:

    猜你喜欢
    • 2019-03-14
    • 2020-05-18
    • 2019-03-26
    • 2019-11-19
    • 2017-10-05
    • 2023-01-30
    • 2021-01-16
    • 2019-12-20
    • 2018-09-11
    相关资源
    最近更新 更多