Skip to content

Commit 047d6cf

Browse files
committed
refactor: remove unused query.setDefaultOptions
1 parent e21ef6c commit 047d6cf

File tree

3 files changed

+4
-23
lines changed

3 files changed

+4
-23
lines changed

docs/src/pages/guides/migrating-to-react-query-4.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ The `useQueries` hook now accepts an object with a `queries` prop as its input.
217217
```
218218

219219

220-
### Removed undocumented methods from the `queryClient`
220+
### Removed undocumented methods from the `queryClient` and `query`
221221

222-
The methods `cancelMutatations` and `executeMutation` were undocumented and unused internally, so we removed them. Since they were just wrappers around methods available on the `mutationCache`, you can still use the functionality.
222+
The methods `cancelMutatations` and `executeMutation` on the `QueryClient` were undocumented and unused internally, so we removed them. Since they were just wrappers around methods available on the `mutationCache`, you can still use the functionality.
223223

224224
```diff
225225
- cancelMutations(): Promise<void> {
@@ -243,6 +243,8 @@ The methods `cancelMutatations` and `executeMutation` were undocumented and unus
243243
- }
244244
```
245245

246+
Additionally, `query.setDefaultOptions` was removed because it was also unused.
247+
246248
### TypeScript
247249

248250
Types now require using TypeScript v4.1 or greater

src/core/query.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,6 @@ export class Query<
188188
this.updateCacheTime(this.options.cacheTime)
189189
}
190190

191-
setDefaultOptions(
192-
options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>
193-
): void {
194-
this.defaultOptions = options
195-
}
196-
197191
protected optionalRemove() {
198192
if (!this.observers.length && this.state.fetchStatus === 'idle') {
199193
this.cache.remove(this)

src/core/tests/query.test.tsx

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -634,21 +634,6 @@ describe('query', () => {
634634
)
635635
})
636636

637-
test('should set default options', async () => {
638-
const key = queryKey()
639-
640-
await queryClient.prefetchQuery(key, () => 'data')
641-
const query = queryCache.find(key)!
642-
643-
query.setDefaultOptions({ retryDelay: 20 })
644-
645-
await queryClient.prefetchQuery(key, () => 'data', {
646-
cacheTime: 100,
647-
})
648-
649-
expect(query.options).toMatchObject({ cacheTime: 100, retryDelay: 20 })
650-
})
651-
652637
test('should refetch the observer when online method is called', async () => {
653638
const key = queryKey()
654639

0 commit comments

Comments
 (0)