Skip to content

Commit

Permalink
feat(useQuery): offline queries
Browse files Browse the repository at this point in the history
guard against illegal state transitions: paused queries can unmount or get cancelled, in which case we shouldn't continue them, even if we dispatch the continue event
  • Loading branch information
TkDodo committed Nov 21, 2021
1 parent 2f97632 commit a647f64
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/core/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,15 +538,19 @@ export class Query<
fetchFailureCount: state.fetchFailureCount + 1,
}
case 'pause':
return {
...state,
fetchStatus: 'paused',
}
return state.fetchStatus === 'fetching'
? {
...state,
fetchStatus: 'paused',
}
: state
case 'continue':
return {
...state,
fetchStatus: 'fetching',
}
return state.fetchStatus === 'paused'
? {
...state,
fetchStatus: 'fetching',
}
: state
case 'fetch':
return {
...state,
Expand Down

0 comments on commit a647f64

Please sign in to comment.