reactjs阿波罗反应取消请求

时间:2020-03-23 06:58:58

标签: reactjs react-apollo apollo-client

我遇到一个问题,即您导航到页面并阿波罗检索数据。当apollo这样做并且您导航到另一个页面时,apollo不会取消请求并引发以下错误:

Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application

是否有任何方法可以取消或中止来自ComponentDidUnmount的请求?

componentDidMount() {
    this.props.client.query({ ... })
}
componentWillUnmount() {
    // cancel or abort query here
}

谢谢!

0 个答案:

没有答案