React Apollo多次重新引用不起作用

问题描述 投票:0回答:1

我正在尝试进行这三次重新引用,但是只有一个正在工作。我不知道问题是什么。

onChangeText={(text) => {
  this.props.searchEvent.refetch({ term: text })
  this.props.searchUser.refetch({ name: text })
  this.props.searchLocation.refetch({ location: text })
  this.setState({ searchTerm: text })
}}
reactjs react-native apollo react-apollo
1个回答
0
投票

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

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 })

                        }}

© www.soinside.com 2019 - 2024. All rights reserved.