Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow onNewData to be called when unmounted, during SSR. #6388

Merged
merged 1 commit into from
Jun 4, 2020
Merged
Changes from all 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
12 changes: 9 additions & 3 deletions src/react/data/QueryData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ export class QueryData<TData, TVariables> extends OperationData {
this.cleanup();
this.runLazy = true;
this.lazyOptions = options;
if (this.isMounted) this.onNewData();
if (this.isMounted || this.ssrInitiated()) {
this.onNewData();
}
};

private getExecuteResult(): QueryResult<TData, TVariables> {
Expand Down Expand Up @@ -291,7 +293,9 @@ export class QueryData<TData, TVariables> extends OperationData {
return;
}

if (this.isMounted) onNewData();
if (this.isMounted || this.ssrInitiated()) {
onNewData();
}
},
error: error => {
this.resubscribeToQuery();
Expand All @@ -303,7 +307,9 @@ export class QueryData<TData, TVariables> extends OperationData {
!equal(error, this.previousData.error)
) {
this.previousData.error = error;
if (this.isMounted) onNewData();
if (this.isMounted || this.ssrInitiated()) {
onNewData();
}
}
}
});
Expand Down