You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat: rename throwErrors to throwOnError
to be aligned with the options we already have on imperative methods, like `invalidateQueries`
* docs: fix outdated code reference
* chore: rename type
* fix: let the refetchInterval function also return undefined
and fall back to false if it does
Copy file name to clipboardExpand all lines: docs/react/guides/migrating-to-v5.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -202,9 +202,9 @@ const queryClient = new QueryClient({
202
202
})
203
203
```
204
204
205
-
### The `useErrorBoundary` option has been renamed to `throwErrors`
205
+
### The `useErrorBoundary` option has been renamed to `throwOnError`
206
206
207
-
To make the `useErrorBoundary` option more framework-agnostic and avoid confusion with the established React function prefix "`use`" for hooks and the "ErrorBoundary" component name, it has been renamed to `throwErrors` to more accurately reflect its functionality.
207
+
To make the `useErrorBoundary` option more framework-agnostic and avoid confusion with the established React function prefix "`use`" for hooks and the "ErrorBoundary" component name, it has been renamed to `throwOnError` to more accurately reflect its functionality.
208
208
209
209
### TypeScript: `Error` is now the default type for errors instead of `unknown`
When using suspense mode, `status` states and `error` objects are not needed and are then replaced by usage of the `React.Suspense` component (including the use of the `fallback` prop and React error boundaries for catching errors). Please read the [Resetting Error Boundaries](#resetting-error-boundaries) and look at the [Suspense Example](https://codesandbox.io/s/github/tannerlinsley/react-query/tree/main/examples/react/suspense) for more information on how to set up suspense mode.
43
43
44
-
In addition to queries behaving differently in suspense mode, mutations also behave a bit differently. By default, instead of supplying the `error` variable when a mutation fails, it will be thrown during the next render of the component it's used in and propagate to the nearest error boundary, similar to query errors. If you wish to disable this, you can set the `throwErrors` option to `false`. If you wish that errors are not thrown at all, you can set the `throwOnError` option to `false` as well!
44
+
In addition to queries behaving differently in suspense mode, mutations also behave a bit differently. By default, instead of supplying the `error` variable when a mutation fails, it will be thrown during the next render of the component it's used in and propagate to the nearest error boundary, similar to query errors. If you wish to disable this, you can set the `throwOnError` option to `false`. If you wish that errors are not thrown at all, you can set the `throwOnError` option to `false` as well!
45
45
46
46
## Resetting Error Boundaries
47
47
48
-
Whether you are using **suspense** or **throwErrors** in your queries, you will need a way to let queries know that you want to try again when re-rendering after some error occurred.
48
+
Whether you are using **suspense** or **throwOnError** in your queries, you will need a way to let queries know that you want to try again when re-rendering after some error occurred.
49
49
50
50
Query errors can be reset with the `QueryErrorResetBoundary` component or with the `useQueryErrorResetBoundary` hook.
Copy file name to clipboardExpand all lines: docs/react/reference/QueryClient.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,7 +91,7 @@ try {
91
91
92
92
**Options**
93
93
94
-
The options for `fetchQuery` are exactly the same as those of [`useQuery`](../reference/useQuery), except the following: `enabled, refetchInterval, refetchIntervalInBackground, refetchOnWindowFocus, refetchOnReconnect, notifyOnChangeProps, onSuccess, onError, onSettled, throwErrors, select, suspense, placeholderData`; which are strictly for useQuery and useInfiniteQuery. You can check the [source code](https://github.com/tannerlinsley/react-query/blob/361935a12cec6f36d0bd6ba12e84136c405047c5/src/core/types.ts#L83) for more clarity.
94
+
The options for `fetchQuery` are exactly the same as those of [`useQuery`](../reference/useQuery), except the following: `enabled, refetchInterval, refetchIntervalInBackground, refetchOnWindowFocus, refetchOnReconnect, refetchOnMount, notifyOnChangeProps, throwOnError, select, suspense, placeholderData`; which are strictly for useQuery and useInfiniteQuery. You can check the [source code](https://github.com/TanStack/query/blob/7cd2d192e6da3df0b08e334ea1cf04cd70478827/packages/query-core/src/types.ts#L119) for more clarity.
Copy file name to clipboardExpand all lines: docs/react/reference/QueryErrorResetBoundary.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ id: QueryErrorResetBoundary
3
3
title: QueryErrorResetBoundary
4
4
---
5
5
6
-
When using **suspense** or **throwErrors** in your queries, you need a way to let queries know that you want to try again when re-rendering after some error occurred. With the `QueryErrorResetBoundary` component you can reset any query errors within the boundaries of the component.
6
+
When using **suspense** or **throwOnError** in your queries, you need a way to let queries know that you want to try again when re-rendering after some error occurred. With the `QueryErrorResetBoundary` component you can reset any query errors within the boundaries of the component.
- Defaults to the global query config's `throwOnError` value, which is `undefined`
89
89
- Set this to `true` if you want mutation errors to be thrown in the render phase and propagate to the nearest error boundary
90
90
- Set this to `false` to disable the behavior of throwing errors to the error boundary.
91
91
- If set to a function, it will be passed the error and should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`)
Copy file name to clipboardExpand all lines: docs/react/reference/useQuery.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,7 +56,7 @@ const {
56
56
staleTime,
57
57
structuralSharing,
58
58
suspense,
59
-
throwErrors,
59
+
throwOnError,
60
60
})
61
61
```
62
62
@@ -101,7 +101,7 @@ const {
101
101
-`queryKeyHashFn: (queryKey: QueryKey) => string`
102
102
- Optional
103
103
- If specified, this function is used to hash the `queryKey` to a string.
104
-
-`refetchInterval: number | false | ((data: TData | undefined, query: Query) => number | false)`
104
+
-`refetchInterval: number | false | ((data: TData | undefined, query: Query) => number | false | undefined)`
105
105
- Optional
106
106
- If set to a number, all queries will continuously refetch at this frequency in milliseconds
107
107
- If set to a function, the function will be executed with the latest data and query to compute a frequency
@@ -171,8 +171,8 @@ const {
171
171
- Defaults to `true`
172
172
- If set to `false`, structural sharing between query results will be disabled.
173
173
- If set to a function, the old and new data values will be passed through this function, which should combine them into resolved data for the query. This way, you can retain references from the old data to improve performance even when that data contains non-serializable values.
- Defaults to the global query config's `throwOnError` value, which is `undefined`
176
176
- Set this to `true` if you want errors to be thrown in the render phase and propagate to the nearest error boundary
177
177
- Set this to `false` to disable `suspense`'s default behavior of throwing errors to the error boundary.
178
178
- If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`)
* If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`).
0 commit comments