Skip to content

Commit b92fb04

Browse files
docs: fix pages breaking due to diff in markdown (#7321)
1 parent 8fa8265 commit b92fb04

File tree

3 files changed

+154
-154
lines changed

3 files changed

+154
-154
lines changed

docs/framework/react/guides/migrating-to-react-query-3.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -425,19 +425,19 @@ Therefore you have to change the enum properties to their equivalent string lite
425425

426426
Here is an example of the changes you would have to make:
427427

428-
```diff
429-
- import { useQuery, QueryStatus } from 'react-query';
430-
+ import { useQuery } from 'react-query';
428+
```tsx
429+
- import { useQuery, QueryStatus } from 'react-query'; // [!code --]
430+
+ import { useQuery } from 'react-query'; // [!code ++]
431431

432432
const { data, status } = useQuery(['post', id], () => fetchPost(id))
433433

434-
- if (status === QueryStatus.Loading) {
435-
+ if (status === 'loading') {
434+
- if (status === QueryStatus.Loading) { // [!code --]
435+
+ if (status === 'loading') { // [!code ++]
436436
...
437437
}
438438

439-
- if (status === QueryStatus.Error) {
440-
+ if (status === 'error') {
439+
- if (status === QueryStatus.Error) { // [!code --]
440+
+ if (status === 'error') { // [!code ++]
441441
...
442442
}
443443
```

docs/framework/react/guides/migrating-to-react-query-4.md

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ npm install @tanstack/react-query
1717
npm install @tanstack/react-query-devtools
1818
```
1919

20-
```diff
21-
- import { useQuery } from 'react-query'
22-
- import { ReactQueryDevtools } from 'react-query/devtools'
20+
```tsx
21+
- import { useQuery } from 'react-query' // [!code --]
22+
- import { ReactQueryDevtools } from 'react-query/devtools' // [!code --]
2323
24-
+ import { useQuery } from '@tanstack/react-query'
25-
+ import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
24+
+ import { useQuery } from '@tanstack/react-query' // [!code ++]
25+
+ import { ReactQueryDevtools } from '@tanstack/react-query-devtools' // [!code ++]
2626
```
2727
2828
#### Codemod
@@ -64,9 +64,9 @@ However, we have not followed this concept through to all apis. For example, whe
6464

6565
To streamline all apis, we've decided to make all keys Arrays only:
6666

67-
```diff
68-
- useQuery('todos', fetchTodos)
69-
+ useQuery(['todos'], fetchTodos)
67+
```tsx
68+
- useQuery('todos', fetchTodos) // [!code --]
69+
+ useQuery(['todos'], fetchTodos) // [!code ++]
7070
```
7171

7272
#### Codemod
@@ -104,10 +104,10 @@ With the introduction of the new [fetchStatus](../queries#fetchstatus) for bette
104104

105105
This will mostly affect `disabled` queries that don't have any `data` yet, as those were in `idle` state before:
106106

107-
```diff
108-
- status: 'idle'
109-
+ status: 'loading'
110-
+ fetchStatus: 'idle'
107+
```tsx
108+
- status: 'idle' // [!code --]
109+
+ status: 'loading' // [!code ++]
110+
+ fetchStatus: 'idle' // [!code ++]
111111
```
112112

113113
Also, have a look at [the guide on dependent queries](../dependent-queries)
@@ -116,9 +116,9 @@ Also, have a look at [the guide on dependent queries](../dependent-queries)
116116

117117
Due to this change, disabled queries (even temporarily disabled ones) will start in `loading` state. To make migration easier, especially for having a good flag to know when to display a loading spinner, you can check for `isInitialLoading` instead of `isLoading`:
118118

119-
```diff
120-
- isLoading
121-
+ isInitialLoading
119+
```tsx
120+
- isLoading // [!code --]
121+
+ isInitialLoading // [!code ++]
122122
```
123123

124124
See also the guide on [disabling queries](../disabling-queries#isInitialLoading)
@@ -127,9 +127,9 @@ See also the guide on [disabling queries](../disabling-queries#isInitialLoading)
127127

128128
The `useQueries` hook now accepts an object with a `queries` prop as its input. The value of the `queries` prop is an array of queries (this array is identical to what was passed into `useQueries` in v3).
129129

130-
```diff
131-
- useQueries([{ queryKey1, queryFn1, options1 }, { queryKey2, queryFn2, options2 }])
132-
+ useQueries({ queries: [{ queryKey1, queryFn1, options1 }, { queryKey2, queryFn2, options2 }] })
130+
```tsx
131+
- useQueries([{ queryKey1, queryFn1, options1 }, { queryKey2, queryFn2, options2 }]) // [!code --]
132+
+ useQueries({ queries: [{ queryKey1, queryFn1, options1 }, { queryKey2, queryFn2, options2 }] }) // [!code ++]
133133
```
134134

135135
### Undefined is an illegal cache value for successful queries
@@ -224,10 +224,10 @@ Those flags don't work well when used together, because they are mutually exclus
224224

225225
With v4, those filters have been combined into a single filter to better show the intent:
226226

227-
```diff
228-
- active?: boolean
229-
- inactive?: boolean
230-
+ type?: 'active' | 'inactive' | 'all'
227+
```tsx
228+
- active?: boolean // [!code --]
229+
- inactive?: boolean // [!code --]
230+
+ type?: 'active' | 'inactive' | 'all' // [!code ++]
231231
```
232232

233233
The filter defaults to `all`, and you can choose to only match `active` or `inactive` queries.
@@ -249,10 +249,10 @@ refetchInactive: Boolean
249249

250250
For the same reason, those have also been combined:
251251

252-
```diff
253-
- refetchActive?: boolean
254-
- refetchInactive?: boolean
255-
+ refetchType?: 'active' | 'inactive' | 'all' | 'none'
252+
```tsx
253+
- refetchActive?: boolean // [!code --]
254+
- refetchInactive?: boolean // [!code --]
255+
+ refetchType?: 'active' | 'inactive' | 'all' | 'none' // [!code ++]
256256
```
257257

258258
This flag defaults to `active` because `refetchActive` defaulted to `true`. This means we also need a way to tell `invalidateQueries` to not refetch at all, which is why a fourth option (`none`) is also allowed here.
@@ -276,14 +276,14 @@ The plugins `createWebStoragePersistor` and `createAsyncStoragePersistor` have b
276276

277277
Since these plugins are no longer experimental, their import paths have also been updated:
278278

279-
```diff
280-
- import { persistQueryClient } from 'react-query/persistQueryClient-experimental'
281-
- import { createWebStoragePersistor } from 'react-query/createWebStoragePersistor-experimental'
282-
- import { createAsyncStoragePersistor } from 'react-query/createAsyncStoragePersistor-experimental'
279+
```tsx
280+
- import { persistQueryClient } from 'react-query/persistQueryClient-experimental' // [!code --]
281+
- import { createWebStoragePersistor } from 'react-query/createWebStoragePersistor-experimental' // [!code --]
282+
- import { createAsyncStoragePersistor } from 'react-query/createAsyncStoragePersistor-experimental' // [!code --]
283283
284-
+ import { persistQueryClient } from '@tanstack/react-query-persist-client'
285-
+ import { createSyncStoragePersister } from '@tanstack/query-sync-storage-persister'
286-
+ import { createAsyncStoragePersister } from '@tanstack/query-async-storage-persister'
284+
+ import { persistQueryClient } from '@tanstack/react-query-persist-client' // [!code ++]
285+
+ import { createSyncStoragePersister } from '@tanstack/query-sync-storage-persister' // [!code ++]
286+
+ import { createAsyncStoragePersister } from '@tanstack/query-async-storage-persister' // [!code ++]
287287
```
288288
289289
### The `cancel` method on promises is no longer supported
@@ -302,13 +302,13 @@ As of v4, React Query is optimized for modern browsers. We have updated our brow
302302
303303
It was possible to change the logger globally by calling `setLogger`. In v4, that function is replaced with an optional field when creating a `QueryClient`.
304304
305-
```diff
306-
- import { QueryClient, setLogger } from 'react-query';
307-
+ import { QueryClient } from '@tanstack/react-query';
305+
```tsx
306+
- import { QueryClient, setLogger } from 'react-query'; // [!code --]
307+
+ import { QueryClient } from '@tanstack/react-query'; // [!code ++]
308308

309-
- setLogger(customLogger)
310-
- const queryClient = new QueryClient();
311-
+ const queryClient = new QueryClient({ logger: customLogger })
309+
- setLogger(customLogger) // [!code --]
310+
- const queryClient = new QueryClient(); // [!code --]
311+
+ const queryClient = new QueryClient({ logger: customLogger }) // [!code ++]
312312
```
313313

314314
### No _default_ manual Garbage Collection server-side
@@ -334,13 +334,13 @@ Subscribing manually to the `QueryCache` has always given you a `QueryCacheNotif
334334

335335
#### QueryCacheNotifyEvent
336336

337-
```diff
338-
- type: 'queryAdded'
339-
+ type: 'added'
340-
- type: 'queryRemoved'
341-
+ type: 'removed'
342-
- type: 'queryUpdated'
343-
+ type: 'updated'
337+
```tsx
338+
- type: 'queryAdded' // [!code --]
339+
+ type: 'added' // [!code ++]
340+
- type: 'queryRemoved' // [!code --]
341+
+ type: 'removed' // [!code ++]
342+
- type: 'queryUpdated' // [!code --]
343+
+ type: 'updated' // [!code ++]
344344
```
345345

346346
#### MutationCacheNotifyEvent
@@ -353,26 +353,26 @@ The `MutationCacheNotifyEvent` uses the same types as the `QueryCacheNotifyEvent
353353

354354
With version [3.22.0](https://github.com/tannerlinsley/react-query/releases/tag/v3.22.0), hydration utilities moved into the React Query core. With v3, you could still use the old exports from `react-query/hydration`, but these exports have been removed with v4.
355355

356-
```diff
357-
- import { dehydrate, hydrate, useHydrate, Hydrate } from 'react-query/hydration'
358-
+ import { dehydrate, hydrate, useHydrate, Hydrate } from '@tanstack/react-query'
356+
```tsx
357+
- import { dehydrate, hydrate, useHydrate, Hydrate } from 'react-query/hydration' // [!code --]
358+
+ import { dehydrate, hydrate, useHydrate, Hydrate } from '@tanstack/react-query' // [!code ++]
359359
```
360360
361361
### Removed undocumented methods from the `queryClient`, `query` and `mutation`
362362
363363
The methods `cancelMutatations` and `executeMutation` on the `QueryClient` were undocumented and unused internally, so we removed them. Since it was just a wrapper around a method available on the `mutationCache`, you can still use the functionality of `executeMutation`
364364
365-
```diff
366-
- executeMutation<
367-
- TData = unknown,
368-
- TError = unknown,
369-
- TVariables = void,
370-
- TContext = unknown
371-
- >(
372-
- options: MutationOptions<TData, TError, TVariables, TContext>
373-
- ): Promise<TData> {
374-
- return this.mutationCache.build(this, options).execute()
375-
- }
365+
```tsx
366+
- executeMutation< // [!code --]
367+
- TData = unknown, // [!code --]
368+
- TError = unknown, // [!code --]
369+
- TVariables = void, // [!code --]
370+
- TContext = unknown // [!code --]
371+
- >( // [!code --]
372+
- options: MutationOptions<TData, TError, TVariables, TContext> // [!code --]
373+
- ): Promise<TData> { // [!code --]
374+
- return this.mutationCache.build(this, options).execute() // [!code --]
375+
- } // [!code --]
376376
```
377377

378378
Additionally, `query.setDefaultOptions` was removed because it was also unused. `mutation.cancel` was removed because it didn't actually cancel the outgoing request.
@@ -389,9 +389,9 @@ With the renamed directory this no longer is an issue.
389389

390390
If you were importing anything from `'react-query/react'` directly in your project (as opposed to just `'react-query'`), then you need to update your imports:
391391

392-
```diff
393-
- import { QueryClientProvider } from 'react-query/react';
394-
+ import { QueryClientProvider } from '@tanstack/react-query/reactjs';
392+
```tsx
393+
- import { QueryClientProvider } from 'react-query/react'; // [!code --]
394+
+ import { QueryClientProvider } from '@tanstack/react-query/reactjs'; // [!code ++]
395395
```
396396

397397
## New Features 🚀

0 commit comments

Comments
 (0)