Skip to content

Commit ac342e2

Browse files
tannerlinsleyboschnicseasjpangelleJakeGinnivan
authored
* feat: initial v3 changes (TanStack#1079) * force website deploy * docs: v3 updates * docs: More documentation improvements * docs: update query filters page * docs: update query keys * docs: more updates * docs: updates * feat: support multiple subscribers in observers * docs: useMutation updates * fix: mutate argument types and state update order * fix: remove cache argument in cache callback * fix: move optimistic fetching state into query observer * fix: make sure default options can be overridden * fix: type improvements * feat: memoize select function result * fix: only suspend when mounting * docs: refactor to top level pages and multiple api reference pages per export * test: add remove query test * feat: add filters client isFetching and useIsFetching hook * docs: temp move docs back to docs directory * docs: solve conflicts * docs: fix queryClient reference * docs: reorg directory structure * docs: fix queryClient reference * docs: fix links * docs: better phrasing * docs: force docs build * docs: update examples * fix: use updatedAt to check for existing data * feat: add structural sharing to select result * refactor: update hashing terminology * test: add ability to wrap react query updates with React act * refactor: replace console with logger implementation * docs: add migration page to navigation * docs: update installation docs * refactor: reduce file size * docs: update examples * fix: always compare query keys as arrays * refactor: mark observers as private * test: update timings in hydration cache time test * docs: Update queries.md (TanStack#1134) * feat: split mutate into mutate and mutateAsync (TanStack#1130) * feat: split mutate into mutate and mutateAsync * docs: Update docs/src/pages/guides/mutations.md Co-authored-by: Tanner Linsley <[email protected]> * feat: add bi-directional infinite query support (TanStack#1135) * refactor: reduce file size * feat: revert to previous state on cancellation * fix: wait for all queries to cancel * docs: update cancellation docs * build: force * build: add beta build * build: add beta build * docs: update comparison * fix: support infinite cache time when hydrating * refactor: explicitly mark package side effects * docs: update comparison * docs: update comparison * fix: remove excess exports * feat: add support for default options when hydrating * docs: fix links * feat: add options to setQueryData * fix: align notify terminology * feat: Major semver bump BREAKING CHANGE: Increment Major Version * fix: always try to fetch if enabled * feat: bump version * fix: refetch should create new query when removed * chore: do not publish beta until we figure this out * make beta prerelease * dry run releases * fix: test dry run semantic release * release beta releases for realzies * test: add eslint rule * docs(useQuery): change manual to enabled (TanStack#1167) * feat: move mutations into the core (TanStack#1162) * feat: tree shake infinite query and support manual updates * docs: update comparison * refactor: remove observer factory * refactor: add subscribable * refactor: move hasListeners * refactor: optimize bundle * fix: add status bools to use mutation result * feat: api update * fix: add defaults to UseMutationOptions type * docs: add pages * fix: cleanup * refactor: use queryCache property directly * docs: Add placeholder data guide * docs: fix typo * fix: keep previous query status when fetching * fix: stop retry when observers unmount * feat: add additional notify flags * fix: only keep notify on stale option * refactor: only batch react callbacks * test: update timings * refactor: also batch in suspense * feat: add hydration support for mutations * fix: remove query immediately if cacheTime is 0 * fix: prevent infinite fetch loop * refactor: move refetch logic into observer * fix: match query key correctly when setting defaults * test: add query defaults test * fix: re-add useMutation callback composition * feat: use set defaults also for observers * test: add enabled assertion * feat: add ability to manually control the online and focus state * docs: update onlineManager documentation * feat: add discriminated unions for query results (TanStack#1247) * fix: only set state in listeners when provided * docs: add testing page * feat: add query function context (TanStack#1261) * feat: add errorUpdatedAt property * fix: only trigger suspense when loading for the first time * fix: make sure suspense is always triggered when loading a query * fix: add ability to type the query key in the query function context * refactor: make isDataEqual type more specific * docs: update react native focus code * fix: make sure to remove the correct query from cache * test: remove only * feat: add granular component re-render control * fix: make sure component re-render when they should * feat: throw error when QueryClientProvider has not been used to set a query client (TanStack#1309) Also updated docs * test: add invalidateQueries test * fix: prevent state update after mutation unmounted * fix: add defaults to setQueryData * fix: cancellations for useInfiniteQuery (TanStack#1359) * chore: update TypeScript version (TanStack#1314) * Merge branch 'master' into beta * fix(hydration): set fetchMeta to null by default to make it serializable (TanStack#1371) * fix(hasPageParam): look for (undefined | null | false) values * chore: fix linting * fix: cross-bundle/version query client context * docs: Update Examples * docs: update example deps * docs: keepPreviousData not set in paginated queries docs (TanStack#1376) * docs: typo infinite instead of ininite (TanStack#1379) * feat: devtools are now native to the core repo/npm-package * feat(persist-localstorage-experimental): temporarily persist cache to disk * tests: fix linting * chore: attempt codesandbox import fix * chore: revert codesandbox fix * fix(persist-localstorage): add ssr-safety * docs: fix typos in migration and queries guide (TanStack#1387) Fix typos in guides/migrating-to-react-query-3 and guides/queries. Fixes TanStack#1378 * docs(typos): fix typos in mutations guide (TanStack#1392) * docs: update migration guide * docs: update comparison * chore: remove vercel.json * docs: update comparison * Update logo.sketch * feat: reset query utils (TanStack#1375) * feat: reset query utils * Update queryClient.ts * Reset query docs and tests (TanStack#1393) * docs: Add resetQueries * test: Add resetQueries tests * remove unnecessary queryCache.reset methods Co-authored-by: Aaron Jensen <[email protected]> * types: fix mutation context type * fix: isFetched and isFetchedAfterMount should include failed fetches * docs: Persist localstorage plugin * feat: resetQueries refetches active queries (TanStack#1397) Co-authored-by: Niek Bosch <[email protected]> Co-authored-by: Abhijeet Singh <[email protected]> Co-authored-by: JP Angelle <[email protected]> Co-authored-by: Jake Ginnivan <[email protected]> Co-authored-by: Tom Klaver <[email protected]> Co-authored-by: Dmitry Ivanov <[email protected]> Co-authored-by: Corentin Leruth <[email protected]> Co-authored-by: ConneXNL <[email protected]> Co-authored-by: Rubén Moya <[email protected]> Co-authored-by: Pascal Wegner <[email protected]> Co-authored-by: Amen SOUISSI <[email protected]> Co-authored-by: Aaron Jensen <[email protected]>
1 parent 8aeb209 commit ac342e2

File tree

280 files changed

+15846
-10858
lines changed

Some content is hidden

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

280 files changed

+15846
-10858
lines changed

.eslintrc

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"parser": "@typescript-eslint/parser",
3-
"plugins": ["@typescript-eslint"],
3+
"plugins": ["@typescript-eslint", "import"],
44
"extends": [
55
"plugin:@typescript-eslint/eslint-recommended",
66
"plugin:@typescript-eslint/recommended",
7+
"plugin:import/typescript",
78
"react-app",
89
"prettier"
910
],
@@ -26,6 +27,10 @@
2627
"ignoreParameters": true
2728
}
2829
],
29-
"no-shadow": "error"
30+
"no-shadow": "error",
31+
"import/no-cycle": "error",
32+
"import/no-unresolved": "error",
33+
"import/no-unused-modules": ["off", { "unusedExports": true }],
34+
"no-redeclare": "off"
3035
}
3136
}

.github/workflows/test-and-publish.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches:
66
- 'master'
7-
- 'next'
7+
- 'beta'
88
- '1.x'
99
pull_request:
1010

@@ -38,7 +38,7 @@ jobs:
3838
registry-url: https://registry.npmjs.org/
3939
- name: Install dependencies
4040
uses: bahmutov/npm-install@v1
41-
- run: yarn build && yarn build:types
41+
- run: yarn build
4242
- run: npx semantic-release@17
4343
env:
4444
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
node_modules
66

77
# builds
8+
types
89
build
910
dist
1011
lib
1112
es
1213
artifacts
1314
.rpt2_cache
1415
coverage
16+
*.tgz
1517

1618
# misc
1719
.DS_Store
@@ -31,5 +33,3 @@ stats-hydration.json
3133
stats-react.json
3234
stats.html
3335
.vscode/settings.json
34-
35-
types

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [React Tabl
3939
- Load-More + Infinite Scroll Queries w/ Scroll Recovery
4040
- Request Cancellation
4141
- [React Suspense](https://reactjs.org/docs/concurrent-mode-suspense.html) + Fetch-As-You-Render Query Prefetching
42-
- [Dedicated Devtools (React Query Devtools)](https://github.com/tannerlinsley/react-query-devtools)
42+
- [Dedicated Devtools
4343
- <a href="https://bundlephobia.com/result?p=react-query@latest" target="\_parent">
4444
<img alt="" src="https://badgen.net/bundlephobia/minzip/react-query@latest" />
4545
</a> (depending on features imported)
@@ -80,4 +80,4 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
8080

8181
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
8282

83-
<!-- Force 1 -->
83+
<!-- Force 2 -->

core/package.json

+6
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+
}

devtools/package.json

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

docs/next.config.js

+10-17
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,21 @@ const remarkPlugins = [
3737
module.exports = optimizedImages({
3838
pageExtensions: ['jsx', 'js', 'mdx', 'md'],
3939
env: {
40-
GA_TRACKING_ID: process.env.GA_TRACKING_ID || '',
40+
NEXT_PUBLIC_GA_TRACKING_ID: process.env.GA_TRACKING_ID || '',
4141
SENTRY_RELEASE: process.env.VERCEL_GITHUB_COMMIT_SHA || '',
4242
},
43+
async redirects() {
44+
return [
45+
{
46+
source: '/docs/:any*',
47+
destination: '/:any*', // Matched parameters can be used in the destination
48+
permanent: true,
49+
},
50+
]
51+
},
4352
experimental: {
4453
plugins: true,
4554
modern: true,
46-
rewrites() {
47-
return [
48-
{
49-
source: '/feed.xml',
50-
destination: '/_next/static/feed.xml',
51-
},
52-
{
53-
source: '/docs{/}?',
54-
destination: '/docs/overview',
55-
},
56-
{
57-
source: '/docs/tag/:tag{/}?',
58-
destination: '/docs/tag/:tag/overview',
59-
},
60-
]
61-
},
6255
},
6356
webpack: (config, { dev, isServer, ...options }) => {
6457
config.module.rules.push({

docs/package.json

+23-23
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,39 @@
1313
"dependencies": {
1414
"@babel/preset-typescript": "^7.10.4",
1515
"@docsearch/react": "1.0.0-alpha.14",
16-
"@mdx-js/loader": "^1.5.1",
17-
"@mdx-js/mdx": "^1.5.1",
18-
"@mdx-js/react": "^1.5.1",
16+
"@mdx-js/loader": "^1.6.18",
17+
"@mdx-js/mdx": "^1.6.18",
18+
"@mdx-js/react": "^1.6.18",
1919
"@mdx-js/tag": "^0.20.3",
20-
"@next/mdx": "^9.4.0",
21-
"@next/plugin-google-analytics": "^9.4.4",
20+
"@next/mdx": "^9.5.3",
21+
"@next/plugin-google-analytics": "^9.5.3",
2222
"@reactions/component": "^2.0.2",
2323
"@zeit/fetch": "^6.0.0",
2424
"@zeit/react-jsx-parser": "^2.0.0",
2525
"async-sema": "^3.1.0",
26-
"body-scroll-lock": "^3.0.1",
26+
"body-scroll-lock": "^3.1.5",
2727
"classnames": "^2.2.6",
2828
"copy-to-clipboard": "^3.3.1",
29-
"date-fns": "^2.12.0",
29+
"date-fns": "^2.16.1",
3030
"docsearch.js": "^2.6.3",
3131
"framer-motion": "^1.11.1",
3232
"gray-matter": "^4.0.2",
3333
"imagemin-mozjpeg": "^9.0.0",
3434
"imagemin-optipng": "^8.0.0",
3535
"intersection-observer": "^0.10.0",
3636
"isomorphic-unfetch": "^3.0.0",
37-
"next": "^9.4.4",
38-
"next-images": "^1.4.0",
39-
"next-optimized-images": "^2.6.1",
40-
"node-fetch": "^2.6.0",
41-
"prismjs": "^1.20.0",
37+
"next": "^9.5.3",
38+
"next-images": "^1.5.0",
39+
"next-optimized-images": "^2.6.2",
40+
"node-fetch": "^2.6.1",
41+
"prismjs": "^1.21.0",
4242
"react": "^16.13.1",
4343
"react-dom": "^16.13.1",
44-
"react-icons": "^3.9.0",
44+
"react-icons": "^3.11.0",
4545
"react-live": "^2.2.2",
4646
"rehype-format": "^3.0.1",
4747
"rehype-stringify": "^7.0.0",
48-
"remark": "^12.0.0",
48+
"remark": "^12.0.1",
4949
"remark-autolink-headings": "^6.0.0",
5050
"remark-emoji": "^2.1.0",
5151
"remark-footnotes": "^1.0.0",
@@ -54,26 +54,26 @@
5454
"remark-slug": "^6.0.0",
5555
"remark-toc": "^7.0.0",
5656
"remark-unwrap-images": "^2.0.0",
57-
"scroll-into-view-if-needed": "^2.2.24",
57+
"scroll-into-view-if-needed": "^2.2.26",
5858
"semver-regex": "^3.1.1",
59-
"unist-util-visit": "^2.0.2"
59+
"unist-util-visit": "^2.0.3"
6060
},
6161
"devDependencies": {
62-
"@babel/cli": "^7.10.4",
63-
"@babel/core": "^7.10.4",
64-
"@babel/plugin-transform-typescript": "^7.10.4",
62+
"@babel/cli": "^7.11.6",
63+
"@babel/core": "^7.11.6",
64+
"@babel/plugin-transform-typescript": "^7.11.0",
6565
"@babel/preset-react": "^7.10.4",
6666
"@tailwindcss/ui": "^0.3.0",
6767
"algoliasearch": "3.35.1",
6868
"babel-preset-react-app": "^9.1.2",
6969
"dotenv-load": "^2.0.0",
7070
"github-slugger": "^1.3.0",
71-
"md5": "^2.2.1",
71+
"md5": "^2.3.0",
7272
"mdast-util-to-string": "^1.1.0",
7373
"postcss-preset-env": "^6.7.0",
74-
"remark-parse": "^8.0.2",
75-
"tailwindcss": "^1.4.6",
76-
"unified": "^9.0.0",
74+
"remark-parse": "^8.0.3",
75+
"tailwindcss": "^1.8.10",
76+
"unified": "^9.2.0",
7777
"webp-loader": "^0.6.0"
7878
},
7979
"engines": {

docs/src/components/DocsPageFooter.js

+16-11
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ function areEqual(prevProps, props) {
1010
}
1111

1212
export const DocsPageFooter = React.memo(({ route, prevRoute, nextRoute }) => {
13-
const editUrl = `${siteConfig.editUrl}${route?.editUrl || route?.path}`
13+
const editUrl =
14+
route?.editUrl || route?.path
15+
? `${siteConfig.editUrl}${route?.editUrl || route?.path}`
16+
: null
1417

1518
return (
1619
<>
@@ -45,16 +48,18 @@ export const DocsPageFooter = React.memo(({ route, prevRoute, nextRoute }) => {
4548
</div>
4649
</div>
4750

48-
<div className="mb-8">
49-
<a
50-
href={editUrl}
51-
target="_blank"
52-
rel="noopener noreferrer"
53-
className="text-gray-600 underline"
54-
>
55-
Edit this page on GitHub
56-
</a>
57-
</div>
51+
{editUrl ? (
52+
<div className="mb-8">
53+
<a
54+
href={editUrl}
55+
target="_blank"
56+
rel="noopener noreferrer"
57+
className="text-gray-600 underline"
58+
>
59+
Edit this page on GitHub
60+
</a>
61+
</div>
62+
) : null}
5863

5964
<div className="py-8 md:flex md:items-center md:py-8 border-t border-b">
6065
<div className="font-semibold text-xl mr-4 text-center mb-4 md:mb-0 md:text-left">

docs/src/components/Footer.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@ export const Footer = props => {
1313
</h4>
1414
<ul className="mt-4">
1515
<li>
16-
<Link href="/docs/overview">
16+
<Link href="/overview">
1717
<a className="text-base leading-6 text-gray-500 hover:text-gray-900">
1818
Docs
1919
</a>
2020
</Link>
2121
</li>
2222
<li className="mt-4">
23-
<Link href="/docs/examples/simple">
23+
<Link href="/examples/simple">
2424
<a className="text-base leading-6 text-gray-500 hover:text-gray-900">
2525
Examples
2626
</a>
2727
</Link>
2828
</li>
2929
<li className="mt-4">
30-
<Link href="/docs/api">
30+
<Link href="/api/useQuery">
3131
<a className="text-base leading-6 text-gray-500 hover:text-gray-900">
3232
API Reference
3333
</a>

docs/src/components/LayoutDocs.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ export const LayoutDocs = props => {
7979
/>
8080
<div className="block">
8181
<>
82-
8382
<div className="container mx-auto pb-12 pt-6 content">
8483
<div className="flex relative">
8584
{!isMobile && (
@@ -89,7 +88,7 @@ export const LayoutDocs = props => {
8988
)}
9089

9190
<div className={s['markdown'] + ' w-full docs'}>
92-
<h1>{props.meta.title}</h1>
91+
<h1 id="_top">{props.meta.title}</h1>
9392
<MDXProvider components={MDXComponents}>
9493
{props.children}
9594
</MDXProvider>
@@ -107,11 +106,11 @@ export const LayoutDocs = props => {
107106
width: 200,
108107
}}
109108
>
110-
<div className="sticky top-24 ">
109+
<div className="sticky top-24 overflow-y-auto">
111110
<h4 className="font-semibold uppercase text-sm mb-2 mt-2 text-gray-500">
112111
On this page
113112
</h4>
114-
<Toc />
113+
<Toc title={props.meta.title} />
115114
</div>
116115
</div>
117116
)}

docs/src/components/Nav.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ export const Nav = () => (
2424
<div className="flex flex-grow items-center justify-between w-3/4 md:w-auto md:justify-end space-x-4 md:space-x-8 h-16">
2525
<div className="flex space-x-4 md:space-x-8 text-sm md:text-base">
2626
<div>
27-
<Link href="/docs/overview">
27+
<Link href="/overview">
2828
<a className="leading-6 font-medium">Docs</a>
2929
</Link>
3030
</div>
3131
<div>
32-
<Link href="/docs/examples/simple">
32+
<Link href="/examples/simple">
3333
<a className="leading-6 font-medium">Examples</a>
3434
</Link>
3535
</div>

docs/src/components/Toc.js

+12-10
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@ import styles from './Toc.module.css'
55
const TOP_OFFSET = 100
66

77
function getHeaderAnchors() {
8-
return Array.prototype.filter.call(
9-
document.getElementsByClassName('anchor'),
10-
function (testElement) {
11-
return (
12-
testElement.parentNode.nodeName === 'H2' ||
13-
testElement.parentNode.nodeName === 'H3'
14-
)
15-
}
16-
)
8+
return [
9+
...document.getElementsByTagName('H1'),
10+
...[...document.getElementsByClassName('anchor')].filter(
11+
el => el.parentNode.nodeName === 'H2' || el.parentNode.nodeName === 'H3'
12+
),
13+
].filter(Boolean)
1714
}
1815

1916
function getHeaderDataFromAnchors(el) {
@@ -24,7 +21,7 @@ function getHeaderDataFromAnchors(el) {
2421
}
2522
}
2623

27-
export const Toc = () => {
24+
export const Toc = ({ title }) => {
2825
const headings = useTocHighlight(
2926
styles.contents__link,
3027
styles['contents__link--active'],
@@ -36,6 +33,11 @@ export const Toc = () => {
3633

3734
return (
3835
<ul className="space-y-3">
36+
<li className="text-sm">
37+
<a className={styles.contents__link} href="#_top">
38+
{title}
39+
</a>
40+
</li>
3941
{headings &&
4042
headings.length > 0 &&
4143
headings.map((h, i) =>

0 commit comments

Comments
 (0)