Skip to content

Commit 2089801

Browse files
committed
feat: initial v3 changes
1 parent e16f3dd commit 2089801

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+3435
-3618
lines changed

core/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"internal": true,
3+
"main": "../lib/core/index.js",
4+
"module": "../es/core/index.js",
5+
"types": "../types/core/index.d.ts"
6+
}

docs/src/pages/docs/api.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const {
5252
const queryInfo = useQuery({
5353
queryKey,
5454
queryFn,
55-
config,
55+
enabled,
5656
})
5757
```
5858
@@ -124,6 +124,9 @@ const queryInfo = useQuery({
124124
- `onSettled: Function(data, error) => data`
125125
- Optional
126126
- This function will fire any time the query is either successfully fetched or errors and be passed either the data or error
127+
- `select: (data) => data`
128+
- Optional
129+
- This option can be used to transform or select a part of the data returned by the query function.
127130
- `suspense: Boolean`
128131
- Optional
129132
- Set this to `true` to enable suspense mode.
@@ -186,7 +189,7 @@ const queryInfo = useQuery({
186189
- The failure count for the query.
187190
- Incremented every time the query fails.
188191
- Reset to `0` when the query succeeds.
189-
- `refetch: Function({ throwOnError }) => Promise<TResult | undefined>`
192+
- `refetch: Function({ throwOnError }) => Promise<TData | undefined>`
190193
- A function to manually refetch the query.
191194
- If the query errors, the error will only be logged. If you want an error to be thrown, pass the `throwOnError: true` option
192195
- `remove: Function() => void`
@@ -253,7 +256,7 @@ The returned properties for `useInfiniteQuery` are identical to the [`useQuery`
253256
254257
- `isFetchingMore: false | 'next' | 'previous'`
255258
- If using `paginated` mode, this will be `true` when fetching more results using the `fetchMore` function.
256-
- `fetchMore: Function(fetchMoreVariableOverride) => Promise<TResult | undefined>`
259+
- `fetchMore: Function(fetchMoreVariableOverride) => Promise<TData | undefined>`
257260
- This function allows you to fetch the next "page" of results.
258261
- `fetchMoreVariableOverride` allows you to optionally override the fetch more variable returned from your `getFetchMore` option to your query function to retrieve the next page of results.
259262
- `canFetchMore: Boolean`
@@ -391,7 +394,7 @@ try {
391394
392395
**Returns**
393396
394-
- `Promise<TResult>`
397+
- `Promise<TData>`
395398
396399
## `queryCache.prefetchQuery`
397400
@@ -436,7 +439,7 @@ The options for `prefetchQuery` are exactly the same as those of [`useQuery`](#u
436439
437440
**Returns**
438441
439-
- `Promise<TResult | undefined>`
442+
- `Promise<TData | undefined>`
440443
- A promise is returned that will either immediately resolve with the query's cached response data, or resolve to the data returned by the fetch function. It **will not** throw an error if the fetch fails. This can be configured by setting the `throwOnError` option to `true`.
441444
442445
## `queryCache.getQueryData`
@@ -837,16 +840,16 @@ function App() {
837840
- `queryCache: QueryCache`
838841
- Instance of QueryCache.
839842

840-
## `ReactQueryErrorResetBoundary`
843+
## `QueryErrorResetBoundary`
841844

842-
When using **suspense** or **useErrorBoundaries** in your queries, you need a way to let queries know that you want to try again when re-rendering after some error occured. With the `ReactQueryErrorResetBoundary` component you can reset any query errors within the boundaries of the component.
845+
When using **suspense** or **useErrorBoundaries** in your queries, you need a way to let queries know that you want to try again when re-rendering after some error occured. With the `QueryErrorResetBoundary` component you can reset any query errors within the boundaries of the component.
843846

844847
```js
845-
import { ReactQueryErrorResetBoundary } from 'react-query'
848+
import { QueryErrorResetBoundary } from 'react-query'
846849
import { ErrorBoundary } from 'react-error-boundary'
847850

848851
const App: React.FC = () => (
849-
<ReactQueryErrorResetBoundary>
852+
<QueryErrorResetBoundary>
850853
{({ reset }) => (
851854
<ErrorBoundary
852855
onReset={reset}
@@ -860,20 +863,20 @@ const App: React.FC = () => (
860863
<Page />
861864
</ErrorBoundary>
862865
)}
863-
</ReactQueryErrorResetBoundary>
866+
</QueryErrorResetBoundary>
864867
)
865868
```
866869

867-
## `useErrorResetBoundary`
870+
## `useQueryErrorResetBoundary`
868871

869-
This hook will reset any query errors within the closest `ReactQueryErrorResetBoundary`. If there is no boundary defined it will reset them globally:
872+
This hook will reset any query errors within the closest `QueryErrorResetBoundary`. If there is no boundary defined it will reset them globally:
870873

871874
```js
872-
import { useErrorResetBoundary } from 'react-query'
875+
import { useQueryErrorResetBoundary } from 'react-query'
873876
import { ErrorBoundary } from 'react-error-boundary'
874877

875878
const App: React.FC = () => {
876-
const { reset } = useErrorResetBoundary()
879+
const { reset } = useQueryErrorResetBoundary()
877880
return (
878881
<ErrorBoundary
879882
onReset={reset}

docs/src/pages/docs/comparison.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Feature/Capability Key:
2828
| Paginated Queries ||||
2929
| Infinite Queries ||||
3030
| Lagged / "Lazy" Queries<sup>1</sup> || 🛑 | 🛑 |
31+
| Selectors || 🛑 ||
3132
| Initial Data ||||
3233
| Scroll Recovery ||||
3334
| Cache Manipulation ||||

0 commit comments

Comments
 (0)