Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Reorder code to avoid setting state on unmounted component #3139

Merged
merged 3 commits into from
Jun 21, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Subscriptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ class Subscription<TData = any, TVariables = any> 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) => {
Expand Down