Skip to content

Commit

Permalink
fix: track data property if promise is tracked
Browse files Browse the repository at this point in the history
if users use the `promise` returned from useQuery, they are actually interested in the `data` it unwraps to. Since the promise doesn't change when data resolves, we would likely miss a re-render
  • Loading branch information
TkDodo committed Sep 2, 2024
1 parent 36d367a commit d1184ba
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/query-core/src/queryObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,9 @@ export class QueryObserver<
if (this.options.throwOnError) {
includedProps.add('error')
}
if (includedProps.has('promise')) {
includedProps.add('data')
}

return Object.keys(this.#currentResult).some((key) => {
const typedKey = key as keyof QueryObserverResult
Expand Down

0 comments on commit d1184ba

Please sign in to comment.