Skip to content

Commit

Permalink
Merge branch 'main' into fix-some-links
Browse files Browse the repository at this point in the history
  • Loading branch information
TkDodo committed Apr 22, 2024
2 parents da1c17e + 5b6c67f commit baf7313
Show file tree
Hide file tree
Showing 80 changed files with 687 additions and 311 deletions.
19 changes: 18 additions & 1 deletion docs/framework/react/guides/mutations.md
Expand Up @@ -267,7 +267,7 @@ try {

## Retry

By default TanStack Query will not retry a mutation on error, but it is possible with the `retry` option:
By default, TanStack Query will not retry a mutation on error, but it is possible with the `retry` option:

[//]: # 'Example9'

Expand Down Expand Up @@ -390,6 +390,23 @@ We also have an extensive [offline example](../../examples/offline) that covers

[//]: # 'Materials'

## Mutation Scopes

Per default, all mutations run in parallel - even if you invoke `.mutate()` of the same mutation multiple times. Mutations can be given a `scope` with an `id` to avoid that. All mutations with the same `scope.id` will run in serial, which means when they are triggered, they will start in `isPaused: true` state if there is already a mutation for that scope in progress. They will be put into a queue and will automatically resume once their time in the queue has come.

[//]: # 'ExampleScopes'

```tsx
const mutation = useMutation({
mutationFn: addTodo,
scope: {
id: 'todo',
},
})
```

[//]: # 'ExampleScopes'

## Further reading

For more information about mutations, have a look at [#12: Mastering Mutations in React Query](../../community/tkdodos-blog#12-mastering-mutations-in-react-query) from
Expand Down
7 changes: 6 additions & 1 deletion docs/framework/react/reference/useMutation.md
Expand Up @@ -23,6 +23,7 @@ const {
} = useMutation({
mutationFn,
gcTime,
meta,
mutationKey,
networkMode,
onError,
Expand All @@ -31,8 +32,8 @@ const {
onSuccess,
retry,
retryDelay,
scope,
throwOnError,
meta,
})

mutate(variables, {
Expand Down Expand Up @@ -85,6 +86,10 @@ mutate(variables, {
- This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds.
- A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff.
- A function like `attempt => attempt * 1000` applies linear backoff.
- `scope: { id: string }`
- Optional
- Defaults to a unique id (so that all mutations run in parallel)
- Mutations with the same scope id will run in serial
- `throwOnError: undefined | boolean | (error: TError) => boolean`
- Defaults to the global query config's `throwOnError` value, which is `undefined`
- Set this to `true` if you want mutation errors to be thrown in the render phase and propagate to the nearest error boundary
Expand Down
4 changes: 2 additions & 2 deletions examples/angular/basic/package.json
Expand Up @@ -17,7 +17,7 @@
"@angular/platform-browser": "^17.3.3",
"@angular/platform-browser-dynamic": "^17.3.3",
"@angular/router": "^17.3.3",
"@tanstack/angular-query-experimental": "^5.30.0",
"@tanstack/angular-query-experimental": "^5.31.0",
"rxjs": "^7.8.1",
"tslib": "^2.6.2",
"zone.js": "^0.14.4"
Expand All @@ -26,7 +26,7 @@
"@angular-devkit/build-angular": "^17.3.3",
"@angular/cli": "^17.3.3",
"@angular/compiler-cli": "^17.3.3",
"@tanstack/angular-query-devtools-experimental": "^5.30.0",
"@tanstack/angular-query-devtools-experimental": "^5.31.0",
"typescript": "5.2.2"
}
}
4 changes: 2 additions & 2 deletions examples/angular/infinite-query-with-max-pages/package.json
Expand Up @@ -17,7 +17,7 @@
"@angular/platform-browser": "^17.3.3",
"@angular/platform-browser-dynamic": "^17.3.3",
"@angular/router": "^17.3.3",
"@tanstack/angular-query-experimental": "^5.30.0",
"@tanstack/angular-query-experimental": "^5.31.0",
"rxjs": "^7.8.1",
"tslib": "^2.6.2",
"zone.js": "^0.14.4"
Expand All @@ -26,7 +26,7 @@
"@angular-devkit/build-angular": "^17.3.3",
"@angular/cli": "^17.3.3",
"@angular/compiler-cli": "^17.3.3",
"@tanstack/angular-query-devtools-experimental": "^5.30.0",
"@tanstack/angular-query-devtools-experimental": "^5.31.0",
"typescript": "5.2.2"
}
}
4 changes: 2 additions & 2 deletions examples/angular/router/package.json
Expand Up @@ -17,7 +17,7 @@
"@angular/platform-browser": "^17.3.3",
"@angular/platform-browser-dynamic": "^17.3.3",
"@angular/router": "^17.3.3",
"@tanstack/angular-query-experimental": "^5.30.0",
"@tanstack/angular-query-experimental": "^5.31.0",
"rxjs": "^7.8.1",
"tslib": "^2.6.2",
"zone.js": "^0.14.4"
Expand All @@ -26,7 +26,7 @@
"@angular-devkit/build-angular": "^17.3.3",
"@angular/cli": "^17.3.3",
"@angular/compiler-cli": "^17.3.3",
"@tanstack/angular-query-devtools-experimental": "^5.30.0",
"@tanstack/angular-query-devtools-experimental": "^5.31.0",
"typescript": "5.2.2"
}
}
4 changes: 2 additions & 2 deletions examples/angular/simple/package.json
Expand Up @@ -17,7 +17,7 @@
"@angular/platform-browser": "^17.3.3",
"@angular/platform-browser-dynamic": "^17.3.3",
"@angular/router": "^17.3.3",
"@tanstack/angular-query-experimental": "^5.30.0",
"@tanstack/angular-query-experimental": "^5.31.0",
"rxjs": "^7.8.1",
"tslib": "^2.6.2",
"zone.js": "^0.14.4"
Expand All @@ -26,7 +26,7 @@
"@angular-devkit/build-angular": "^17.3.3",
"@angular/cli": "^17.3.3",
"@angular/compiler-cli": "^17.3.3",
"@tanstack/angular-query-devtools-experimental": "^5.30.0",
"@tanstack/angular-query-devtools-experimental": "^5.31.0",
"typescript": "5.2.2"
}
}
4 changes: 2 additions & 2 deletions examples/react/algolia/package.json
Expand Up @@ -11,8 +11,8 @@
"dependencies": {
"@algolia/client-search": "4.22.1",
"@algolia/transporter": "4.22.1",
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-query-devtools": "^5.29.2",
"@tanstack/react-query": "^5.31.0",
"@tanstack/react-query-devtools": "^5.31.0",
"algoliasearch": "4.22.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/react/auto-refetching/package.json
Expand Up @@ -7,8 +7,8 @@
"start": "next start"
},
"dependencies": {
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-query-devtools": "^5.29.2",
"@tanstack/react-query": "^5.31.0",
"@tanstack/react-query-devtools": "^5.31.0",
"axios": "^1.6.7",
"isomorphic-unfetch": "4.0.2",
"next": "^14.0.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/basic-graphql-request/package.json
Expand Up @@ -8,8 +8,8 @@
"preview": "vite preview"
},
"dependencies": {
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-query-devtools": "^5.29.2",
"@tanstack/react-query": "^5.31.0",
"@tanstack/react-query-devtools": "^5.31.0",
"graphql": "^16.8.1",
"graphql-request": "^6.1.0",
"react": "^18.2.0",
Expand Down
8 changes: 4 additions & 4 deletions examples/react/basic-typescript/package.json
Expand Up @@ -9,10 +9,10 @@
"test:types": "tsc"
},
"dependencies": {
"@tanstack/query-sync-storage-persister": "^5.29.0",
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-query-devtools": "^5.29.2",
"@tanstack/react-query-persist-client": "^5.29.2",
"@tanstack/query-sync-storage-persister": "^5.31.0",
"@tanstack/react-query": "^5.31.0",
"@tanstack/react-query-devtools": "^5.31.0",
"@tanstack/react-query-persist-client": "^5.31.0",
"axios": "^1.6.7",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/react/basic/package.json
Expand Up @@ -8,8 +8,8 @@
"preview": "vite preview"
},
"dependencies": {
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-query-devtools": "^5.29.2",
"@tanstack/react-query": "^5.31.0",
"@tanstack/react-query-devtools": "^5.31.0",
"axios": "^1.6.7",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/react/default-query-function/package.json
Expand Up @@ -8,8 +8,8 @@
"preview": "vite preview"
},
"dependencies": {
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-query-devtools": "^5.29.2",
"@tanstack/react-query": "^5.31.0",
"@tanstack/react-query-devtools": "^5.31.0",
"axios": "^1.6.7",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/react/infinite-query-with-max-pages/package.json
Expand Up @@ -7,8 +7,8 @@
"start": "next start"
},
"dependencies": {
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-query-devtools": "^5.29.2",
"@tanstack/react-query": "^5.31.0",
"@tanstack/react-query-devtools": "^5.31.0",
"axios": "^1.6.7",
"isomorphic-unfetch": "4.0.2",
"next": "^14.0.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/load-more-infinite-scroll/package.json
Expand Up @@ -7,8 +7,8 @@
"start": "next start"
},
"dependencies": {
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-query-devtools": "^5.29.2",
"@tanstack/react-query": "^5.31.0",
"@tanstack/react-query-devtools": "^5.31.0",
"axios": "^1.6.7",
"isomorphic-unfetch": "4.0.2",
"next": "^14.0.0",
Expand Down
6 changes: 3 additions & 3 deletions examples/react/nextjs-suspense-streaming/package.json
Expand Up @@ -8,9 +8,9 @@
"test:types": "tsc"
},
"dependencies": {
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-query-devtools": "^5.29.2",
"@tanstack/react-query-next-experimental": "^5.29.2",
"@tanstack/react-query": "^5.31.0",
"@tanstack/react-query-devtools": "^5.31.0",
"@tanstack/react-query-next-experimental": "^5.31.0",
"next": "^14.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/nextjs/package.json
Expand Up @@ -7,8 +7,8 @@
"start": "next start"
},
"dependencies": {
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-query-devtools": "^5.29.2",
"@tanstack/react-query": "^5.31.0",
"@tanstack/react-query-devtools": "^5.31.0",
"ky": "^1.2.0",
"next": "^14.0.0",
"react": "^18.2.0",
Expand Down
8 changes: 4 additions & 4 deletions examples/react/offline/package.json
Expand Up @@ -8,11 +8,11 @@
"preview": "vite preview"
},
"dependencies": {
"@tanstack/query-sync-storage-persister": "^5.29.0",
"@tanstack/query-sync-storage-persister": "^5.31.0",
"@tanstack/react-location": "^3.7.4",
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-query-devtools": "^5.29.2",
"@tanstack/react-query-persist-client": "^5.29.2",
"@tanstack/react-query": "^5.31.0",
"@tanstack/react-query-devtools": "^5.31.0",
"@tanstack/react-query-persist-client": "^5.31.0",
"ky": "^1.2.0",
"msw": "^2.1.7",
"react": "^18.2.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/optimistic-updates-cache/package.json
Expand Up @@ -8,8 +8,8 @@
"test:types": "tsc"
},
"dependencies": {
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-query-devtools": "^5.29.2",
"@tanstack/react-query": "^5.31.0",
"@tanstack/react-query-devtools": "^5.31.0",
"axios": "^1.6.7",
"isomorphic-unfetch": "4.0.2",
"next": "^14.0.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/optimistic-updates-ui/package.json
Expand Up @@ -7,8 +7,8 @@
"start": "next start"
},
"dependencies": {
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-query-devtools": "^5.29.2",
"@tanstack/react-query": "^5.31.0",
"@tanstack/react-query-devtools": "^5.31.0",
"axios": "^1.6.7",
"isomorphic-unfetch": "4.0.2",
"next": "^14.0.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/pagination/package.json
Expand Up @@ -7,8 +7,8 @@
"start": "next start"
},
"dependencies": {
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-query-devtools": "^5.29.2",
"@tanstack/react-query": "^5.31.0",
"@tanstack/react-query-devtools": "^5.31.0",
"axios": "^1.6.7",
"isomorphic-unfetch": "4.0.2",
"next": "^14.0.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/playground/package.json
Expand Up @@ -8,8 +8,8 @@
"preview": "vite preview"
},
"dependencies": {
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-query-devtools": "^5.29.2",
"@tanstack/react-query": "^5.31.0",
"@tanstack/react-query-devtools": "^5.31.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/react/prefetching/package.json
Expand Up @@ -7,8 +7,8 @@
"start": "next start"
},
"dependencies": {
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-query-devtools": "^5.29.2",
"@tanstack/react-query": "^5.31.0",
"@tanstack/react-query-devtools": "^5.31.0",
"axios": "^1.6.7",
"isomorphic-unfetch": "4.0.2",
"next": "^14.0.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/react-native/package.json
Expand Up @@ -14,8 +14,8 @@
"@react-native-community/netinfo": "^11.1.0",
"@react-navigation/native": "^6.1.6",
"@react-navigation/stack": "^6.3.16",
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-query-devtools": "^5.29.2",
"@tanstack/react-query": "^5.31.0",
"@tanstack/react-query-devtools": "^5.31.0",
"expo": "^50.0.6",
"expo-constants": "^15.4.5",
"expo-status-bar": "^1.11.1",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/react-router/package.json
Expand Up @@ -9,8 +9,8 @@
"test:types": "tsc"
},
"dependencies": {
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-query-devtools": "^5.29.2",
"@tanstack/react-query": "^5.31.0",
"@tanstack/react-query-devtools": "^5.31.0",
"localforage": "^1.10.0",
"match-sorter": "^6.3.4",
"react": "^18.2.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/rick-morty/package.json
Expand Up @@ -12,8 +12,8 @@
"@emotion/styled": "^11.11.0",
"@mui/material": "^5.15.2",
"@mui/styles": "^5.15.2",
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-query-devtools": "^5.29.2",
"@tanstack/react-query": "^5.31.0",
"@tanstack/react-query-devtools": "^5.31.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router": "^6.22.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/shadow-dom/package.json
Expand Up @@ -10,8 +10,8 @@
"preview": "vite preview"
},
"dependencies": {
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-query-devtools": "^5.29.2",
"@tanstack/react-query": "^5.31.0",
"@tanstack/react-query-devtools": "^5.31.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/react/simple/package.json
Expand Up @@ -8,8 +8,8 @@
"preview": "vite preview"
},
"dependencies": {
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-query-devtools": "^5.29.2",
"@tanstack/react-query": "^5.31.0",
"@tanstack/react-query-devtools": "^5.31.0",
"axios": "^1.6.7",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/react/star-wars/package.json
Expand Up @@ -12,8 +12,8 @@
"@emotion/styled": "^11.11.0",
"@mui/material": "^5.15.2",
"@mui/styles": "^5.15.2",
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-query-devtools": "^5.29.2",
"@tanstack/react-query": "^5.31.0",
"@tanstack/react-query-devtools": "^5.31.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router": "^6.22.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/suspense/package.json
Expand Up @@ -3,8 +3,8 @@
"private": true,
"type": "module",
"dependencies": {
"@tanstack/react-query": "^5.29.2",
"@tanstack/react-query-devtools": "^5.29.2",
"@tanstack/react-query": "^5.31.0",
"@tanstack/react-query-devtools": "^5.31.0",
"axios": "^1.6.7",
"font-awesome": "^4.7.0",
"react": "^18.2.0",
Expand Down

0 comments on commit baf7313

Please sign in to comment.