Skip to content

Commit 07d81b9

Browse files
committed
feat: initial v3 changes
1 parent e200c99 commit 07d81b9

Some content is hidden

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

51 files changed

+2359
-3377
lines changed

docs/src/pages/docs/api.md

Lines changed: 14 additions & 11 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,13 +863,13 @@ const App: React.FC = () => (
860863
<Page />
861864
</ErrorBoundary>
862865
)}
863-
</ReactQueryErrorResetBoundary>
866+
</QueryErrorResetBoundary>
864867
)
865868
```
866869

867870
## `useErrorResetBoundary`
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
872875
import { useErrorResetBoundary } from 'react-query'

docs/src/pages/docs/guides/suspense.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ In addition to queries behaving differently in suspense mode, mutations also beh
4747

4848
Whether you are using **suspense** or **useErrorBoundaries** in your queries, you will need a way to let queries know that you want to try again when re-rendering after some error occured.
4949

50-
Query errors can be reset with the `ReactQueryErrorResetBoundary` component or with the `useErrorResetBoundary` hook.
50+
Query errors can be reset with the `QueryErrorResetBoundary` component or with the `useErrorResetBoundary` hook.
5151

5252
When using the component it will reset any query errors within the boundaries of the component:
5353

5454
```js
55-
import { ReactQueryErrorResetBoundary } from 'react-query'
55+
import { QueryErrorResetBoundary } from 'react-query'
5656
import { ErrorBoundary } from 'react-error-boundary'
5757

5858
const App: React.FC = () => (
59-
<ReactQueryErrorResetBoundary>
59+
<QueryErrorResetBoundary>
6060
{({ reset }) => (
6161
<ErrorBoundary
6262
onReset={reset}
@@ -70,11 +70,11 @@ const App: React.FC = () => (
7070
<Page />
7171
</ErrorBoundary>
7272
)}
73-
</ReactQueryErrorResetBoundary>
73+
</QueryErrorResetBoundary>
7474
)
7575
```
7676

77-
When using the hook it will reset any query errors within the closest `ReactQueryErrorResetBoundary`. If there is no boundary defined it will reset them globally:
77+
When using the hook it will reset any query errors within the closest `QueryErrorResetBoundary`. If there is no boundary defined it will reset them globally:
7878

7979
```js
8080
import { useErrorResetBoundary } from 'react-query'

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ module.exports = {
44
testMatch: ['<rootDir>/src/**/*.test.tsx'],
55
testPathIgnorePatterns: ['<rootDir>/types/'],
66
moduleNameMapper: {
7-
'react-query': '<rootDir>/src/react/index.ts',
7+
'react-query': '<rootDir>/src/index.ts',
88
},
99
}

rollup.config.js

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -27,37 +27,6 @@ const babelConfig = { extensions, runtimeHelpers: true }
2727
const resolveConfig = { extensions }
2828

2929
export default [
30-
{
31-
input: inputSrc,
32-
output: {
33-
file: 'dist/react-query.mjs',
34-
format: 'es',
35-
sourcemap: true,
36-
},
37-
external,
38-
plugins: [
39-
resolve(resolveConfig),
40-
babel(babelConfig),
41-
commonJS(),
42-
externalDeps(),
43-
],
44-
},
45-
{
46-
input: inputSrc,
47-
output: {
48-
file: 'dist/react-query.min.mjs',
49-
format: 'es',
50-
sourcemap: true,
51-
},
52-
external,
53-
plugins: [
54-
resolve(resolveConfig),
55-
babel(babelConfig),
56-
commonJS(),
57-
externalDeps(),
58-
terser(),
59-
],
60-
},
6130
{
6231
input: inputSrc,
6332
output: {
@@ -99,37 +68,6 @@ export default [
9968
}),
10069
],
10170
},
102-
{
103-
input: hydrationSrc,
104-
output: {
105-
file: 'dist/hydration/react-query-hydration.mjs',
106-
format: 'es',
107-
sourcemap: true,
108-
},
109-
external: hydrationExternal,
110-
plugins: [
111-
resolve(resolveConfig),
112-
babel(babelConfig),
113-
commonJS(),
114-
externalDeps(),
115-
],
116-
},
117-
{
118-
input: hydrationSrc,
119-
output: {
120-
file: 'dist/hydration/react-query-hydration.min.mjs',
121-
format: 'es',
122-
sourcemap: true,
123-
},
124-
external: hydrationExternal,
125-
plugins: [
126-
resolve(resolveConfig),
127-
babel(babelConfig),
128-
commonJS(),
129-
externalDeps(),
130-
terser(),
131-
],
132-
},
13371
{
13472
input: hydrationSrc,
13573
output: {

0 commit comments

Comments
 (0)