diff --git a/Changelog.md b/Changelog.md index f8aa35c8d4..40309c90ff 100644 --- a/Changelog.md +++ b/Changelog.md @@ -31,6 +31,9 @@ responses couldn't be handled). The `Query` component can now handle an error in a response, then continue to handle a valid response afterwards.
[@hwillson](https://github.com/hwillson) in [#3107](https://github.com/apollographql/react-apollo/pull/3107) +- Reorder `Subscription` component code to avoid setting state on unmounted + component.
+ [@jasonpaulos](https://github.com/jasonpaulos) in [#3139](https://github.com/apollographql/react-apollo/pull/3139) ## 2.5.6 (2019-05-22) diff --git a/src/Subscriptions.tsx b/src/Subscriptions.tsx index 178ae3d2de..44475c014d 100644 --- a/src/Subscriptions.tsx +++ b/src/Subscriptions.tsx @@ -153,12 +153,12 @@ class Subscription extends React.Component< client, props: { onSubscriptionData }, } = this; - if (onSubscriptionData) onSubscriptionData({ client, subscriptionData: result }); this.setState({ data: result.data, loading: false, error: undefined, }); + if (onSubscriptionData) onSubscriptionData({ client, subscriptionData: result }); }; private updateError = (error: any) => {