Skip to content

Commit 712475b

Browse files
committed
Merge remote-tracking branch 'tannerlinsley/main' into beta
RELEASE ALL
2 parents 0bb7605 + f231f8c commit 712475b

25 files changed

+1667
-115
lines changed

docs/adapters/react-query.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { QueryClient, QueryClientProvider, useQuery } from '@tanstack/react-quer
1212
const queryClient = new QueryClient()
1313

1414
function Example() {
15-
const query = useQuery('todos', fetchTodos)
15+
const query = useQuery(['todos'], fetchTodos)
1616

1717
return (
1818
<div>

docs/comparison.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Feature/Capability Key:
6565

6666
> **<sup>1</sup> Lagged Query Data** - React Query provides a way to continue to see an existing query's data while the next query loads (similar to the same UX that suspense will soon provide natively). This is extremely important when writing pagination UIs or infinite loading UIs where you do not want to show a hard loading state whenever a new query is requested. Other libraries do not have this capability and render a hard loading state for the new query (unless it has been prefetched), while the new query loads.
6767
68-
> **<sup>2</sup> Render Optimization** - React Query has excellent rendering performance. By default, it will automatically track which fields are accessed and only re-render if one of them changes. If you would like to opt-out of this optimization, setting `notifyOnChangeProps` to `'all'` will re-render your components whenever the query is updated. For example because it has new data, or to indicate it is fetching. React Query also batches updates together to make sure your application only re-renders once when multiple components are using the same query. If you are only interested in the `data` or `error` properties, you can reduce the number of renders even more by setting `notifyOnChangeProps` to `['data', 'error']`.
68+
> **<sup>2</sup> Render Optimization** - React Query has excellent rendering performance. By default, it will automatically track which fields are accessed and only re-render if one of them changes. If you would like to opt-out of this optimization, setting `notifyOnChangeProps` to `'all'` will re-render your components whenever the query is updated. For example because it has new data, or to indicate it is fetching. React Query also batches updates together to make sure your application only re-renders once when multiple components are using the same query. If you are only interested in the `data` or `error` properties, you can reduce the number of renders even more by setting `notifyOnChangeProps` to `['data', 'error']`.
6969
7070
> **<sup>3</sup> Partial query matching** - Because React Query uses deterministic query key serialization, this allows you to manipulate variable groups of queries without having to know each individual query-key that you want to match, eg. you can refetch every query that starts with `todos` in its key, regardless of variables, or you can target specific queries with (or without) variables or nested properties, and even use a filter function to only match queries that pass your specific conditions.
7171
@@ -79,31 +79,23 @@ Feature/Capability Key:
7979
8080
> **<sup>8</sup> React Router cache persistence** - React Router does not cache data beyond the currently matched routes. If a route is left, its data is lost.
8181
82-
<!-- -->
83-
8482
[bpl-react-query]: https://bundlephobia.com/result?p=react-query
8583
[bp-react-query]: https://badgen.net/bundlephobia/minzip/react-query?label=💾
8684
[gh-react-query]: https://github.com/tannerlinsley/react-query
8785
[stars-react-query]: https://img.shields.io/github/stars/tannerlinsley/react-query?label=%F0%9F%8C%9F
8886

89-
<!-- -->
90-
9187
[swr]: https://github.com/vercel/swr
9288
[bp-swr]: https://badgen.net/bundlephobia/minzip/swr?label=💾
9389
[gh-swr]: https://github.com/vercel/swr
9490
[stars-swr]: https://img.shields.io/github/stars/vercel/swr?label=%F0%9F%8C%9F
9591
[bpl-swr]: https://bundlephobia.com/result?p=swr
9692

97-
<!-- -->
98-
9993
[apollo]: https://github.com/apollographql/apollo-client
10094
[bp-apollo]: https://badgen.net/bundlephobia/minzip/@apollo/client?label=💾
10195
[gh-apollo]: https://github.com/apollographql/apollo-client
10296
[stars-apollo]: https://img.shields.io/github/stars/apollographql/apollo-client?label=%F0%9F%8C%9F
10397
[bpl-apollo]: https://bundlephobia.com/result?p=@apollo/client
10498

105-
<!-- -->
106-
10799
[rtk-query]: https://redux-toolkit.js.org/rtk-query/overview
108100
[rtk-query-comparison]: https://redux-toolkit.js.org/rtk-query/comparison
109101
[rtk-query-bundle-size]: https://redux-toolkit.js.org/rtk-query/comparison#bundle-size
@@ -114,8 +106,6 @@ Feature/Capability Key:
114106
[bpl-rtk]: https://bundlephobia.com/result?p=@reduxjs/toolkit
115107
[bpl-rtk-query]: https://bundlephobia.com/package/@reduxjs/toolkit
116108

117-
<!-- -->
118-
119109
[react-router]: https://github.com/remix-run/react-router
120110
[bp-react-router]: https://badgen.net/bundlephobia/minzip/react-router-dom?label=💾
121111
[gh-react-router]: https://github.com/remix-run/react-router

docs/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,10 @@
276276
"label": "React Native",
277277
"to": "examples/react/react-native"
278278
},
279+
{
280+
"label": "React Router",
281+
"to": "examples/react/react-router"
282+
},
279283
{
280284
"label": "Offline Queries and Mutations",
281285
"to": "examples/react/offline"

docs/guides/background-fetching-indicators.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ A query's `status === 'loading'` state is sufficient enough to show the initial
88
```tsx
99
function Todos() {
1010
const { status, data: todos, error, isFetching } = useQuery(
11-
'todos',
11+
['todos'],
1212
fetchTodos
1313
)
1414

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,17 @@ You can easily apply it by using one (or both) of the following commands:
2828
If you want to run it against `.js` or `.jsx` files, please use the command below:
2929

3030
```
31-
npx jscodeshift ./path/to/src/
32-
--extensions=js,jsx
31+
npx jscodeshift ./path/to/src/ \
32+
--extensions=js,jsx \
3333
--transform=./node_modules/@tanstack/react-query/codemods/v4/replace-import-specifier.js
34-
3534
```
3635

3736
If you want to run it against `.ts` or `.tsx` files, please use the command below:
3837

3938
```
40-
npx jscodeshift ./path/to/src/
41-
--extensions=ts,tsx
42-
--parser=tsx
39+
npx jscodeshift ./path/to/src/ \
40+
--extensions=ts,tsx \
41+
--parser=tsx \
4342
--transform=./node_modules/@tanstack/react-query/codemods/v4/replace-import-specifier.js
4443
```
4544

@@ -73,17 +72,17 @@ You can easily apply it by using one (or both) of the following commands:
7372
If you want to run it against `.js` or `.jsx` files, please use the command below:
7473

7574
```
76-
npx jscodeshift ./path/to/src/
77-
--extensions=js,jsx
75+
npx jscodeshift ./path/to/src/ \
76+
--extensions=js,jsx \
7877
--transform=./node_modules/@tanstack/react-query/codemods/v4/key-transformation.js
7978
```
8079

8180
If you want to run it against `.ts` or `.tsx` files, please use the command below:
8281

8382
```
84-
npx jscodeshift ./path/to/src/
85-
--extensions=ts,tsx
86-
--parser=tsx
83+
npx jscodeshift ./path/to/src/ \
84+
--extensions=ts,tsx \
85+
--parser=tsx \
8786
--transform=./node_modules/@tanstack/react-query/codemods/v4/key-transformation.js
8887
```
8988

docs/guides/queries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: Queries
55

66
## Query Basics
77

8-
A query is a declarative dependency on an asynchronous source of data that is tied to a **unique key**. A query can be used with any Promise based method (including GET and POST methods) to fetch data from a server. If your method modifies data on the server, we recommend using [Mutations](https://react-query.tanstack.com/docs/guides/mutations) instead.
8+
A query is a declarative dependency on an asynchronous source of data that is tied to a **unique key**. A query can be used with any Promise based method (including GET and POST methods) to fetch data from a server. If your method modifies data on the server, we recommend using [Mutations](../guides/mutations) instead.
99

1010
To subscribe to a query in your components or custom hooks, call the `useQuery` hook with at least:
1111

docs/guides/query-cancellation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ An `AbortSignal` can be set in the client `request` method.
100100
```tsx
101101
const client = new GraphQLClient(endpoint)
102102

103-
const query = useQuery('todos', ({ signal }) => {
103+
const query = useQuery(['todos'], ({ signal }) => {
104104
client.request({ document: query, signal })
105105
})
106106
```

examples/react/react-router/.eslintrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": ["react-app", "prettier"],
3+
"rules": {
4+
// "eqeqeq": 0,
5+
// "jsx-a11y/anchor-is-valid": 0
6+
}
7+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
yarn.lock
15+
package-lock.json
16+
17+
# misc
18+
.DS_Store
19+
.env.local
20+
.env.development.local
21+
.env.test.local
22+
.env.production.local
23+
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

examples/react/react-router/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# React Router Example
2+
3+
To run this example:
4+
5+
- `npm install`
6+
- `npm run dev`
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="icon" type="image/svg+xml" href="/emblem-light.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
<meta name="theme-color" content="#000000" />
8+
9+
<title>Tanstack Query React Router Example App</title>
10+
</head>
11+
<body>
12+
<noscript>You need to enable JavaScript to run this app.</noscript>
13+
<div id="root"></div>
14+
<script type="module" src="/src/index.jsx"></script>
15+
</body>
16+
</html>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "@tanstack/query-example-react-router",
3+
"private": true,
4+
"version": "0.0.1",
5+
"main": "src/index.jsx",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "vite build",
9+
"preview": "vite preview"
10+
},
11+
"dependencies": {
12+
"localforage": "^1.10.0",
13+
"match-sorter": "^6.3.1",
14+
"react": "^18.0.0",
15+
"react-dom": "^18.0.0",
16+
"react-router-dom": "^6.4.0-pre.13",
17+
"rooks": "^6.4.3",
18+
"sort-by": "^1.2.0",
19+
"@tanstack/react-query": "4.2.1",
20+
"@tanstack/react-query-devtools": "4.2.1"
21+
},
22+
"devDependencies": {
23+
"@vitejs/plugin-react": "^2.0.0",
24+
"vite": "^3.0.0"
25+
},
26+
"browserslist": {
27+
"production": [
28+
">0.2%",
29+
"not dead",
30+
"not op_mini all"
31+
],
32+
"development": [
33+
"last 1 chrome version",
34+
"last 1 firefox version",
35+
"last 1 safari version"
36+
]
37+
}
38+
}
Lines changed: 13 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)