Skip to content

Commit

Permalink
v3 (#1360)
Browse files Browse the repository at this point in the history
* feat: initial v3 changes (#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 (#1134)

* feat: split mutate into mutate and mutateAsync (#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 (#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 (#1167)

* feat: move mutations into the core (#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 (#1247)

* fix: only set state in listeners when provided

* docs: add testing page

* feat: add query function context (#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 (#1309)

Also updated docs

* test: add invalidateQueries test

* fix: prevent state update after mutation unmounted

* fix: add defaults to setQueryData

* fix: cancellations for useInfiniteQuery (#1359)

* chore: update TypeScript version (#1314)

* Merge branch 'master' into beta

* fix(hydration): set fetchMeta to null by default to make it serializable (#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 (#1376)

* docs: typo infinite instead of ininite (#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 (#1387)

Fix typos in guides/migrating-to-react-query-3 and guides/queries.

Fixes #1378

* docs(typos): fix typos in mutations guide (#1392)

* docs: update migration guide

* docs: update comparison

* chore: remove vercel.json

* docs: update comparison

* Update logo.sketch

* feat: reset query utils (#1375)

* feat: reset query utils

* Update queryClient.ts

* Reset query docs and tests (#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 (#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]>
  • Loading branch information
13 people authored Dec 14, 2020
1 parent 8aeb209 commit ac342e2
Show file tree
Hide file tree
Showing 280 changed files with 15,846 additions and 10,858 deletions.
9 changes: 7 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"plugins": ["@typescript-eslint", "import"],
"extends": [
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/typescript",
"react-app",
"prettier"
],
Expand All @@ -26,6 +27,10 @@
"ignoreParameters": true
}
],
"no-shadow": "error"
"no-shadow": "error",
"import/no-cycle": "error",
"import/no-unresolved": "error",
"import/no-unused-modules": ["off", { "unusedExports": true }],
"no-redeclare": "off"
}
}
4 changes: 2 additions & 2 deletions .github/workflows/test-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- 'master'
- 'next'
- 'beta'
- '1.x'
pull_request:

Expand Down Expand Up @@ -38,7 +38,7 @@ jobs:
registry-url: https://registry.npmjs.org/
- name: Install dependencies
uses: bahmutov/npm-install@v1
- run: yarn build && yarn build:types
- run: yarn build
- run: npx semantic-release@17
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
node_modules

# builds
types
build
dist
lib
es
artifacts
.rpt2_cache
coverage
*.tgz

# misc
.DS_Store
Expand All @@ -31,5 +33,3 @@ stats-hydration.json
stats-react.json
stats.html
.vscode/settings.json

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

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

<!-- Force 1 -->
<!-- Force 2 -->
6 changes: 6 additions & 0 deletions core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"internal": true,
"main": "../lib/core/index.js",
"module": "../es/core/index.js",
"types": "../types/core/index.d.ts"
}
6 changes: 6 additions & 0 deletions devtools/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"internal": true,
"main": "../lib/devtools/index.js",
"module": "../es/devtools/index.js",
"types": "../types/devtools/index.d.ts"
}
27 changes: 10 additions & 17 deletions docs/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,21 @@ const remarkPlugins = [
module.exports = optimizedImages({
pageExtensions: ['jsx', 'js', 'mdx', 'md'],
env: {
GA_TRACKING_ID: process.env.GA_TRACKING_ID || '',
NEXT_PUBLIC_GA_TRACKING_ID: process.env.GA_TRACKING_ID || '',
SENTRY_RELEASE: process.env.VERCEL_GITHUB_COMMIT_SHA || '',
},
async redirects() {
return [
{
source: '/docs/:any*',
destination: '/:any*', // Matched parameters can be used in the destination
permanent: true,
},
]
},
experimental: {
plugins: true,
modern: true,
rewrites() {
return [
{
source: '/feed.xml',
destination: '/_next/static/feed.xml',
},
{
source: '/docs{/}?',
destination: '/docs/overview',
},
{
source: '/docs/tag/:tag{/}?',
destination: '/docs/tag/:tag/overview',
},
]
},
},
webpack: (config, { dev, isServer, ...options }) => {
config.module.rules.push({
Expand Down
46 changes: 23 additions & 23 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,39 @@
"dependencies": {
"@babel/preset-typescript": "^7.10.4",
"@docsearch/react": "1.0.0-alpha.14",
"@mdx-js/loader": "^1.5.1",
"@mdx-js/mdx": "^1.5.1",
"@mdx-js/react": "^1.5.1",
"@mdx-js/loader": "^1.6.18",
"@mdx-js/mdx": "^1.6.18",
"@mdx-js/react": "^1.6.18",
"@mdx-js/tag": "^0.20.3",
"@next/mdx": "^9.4.0",
"@next/plugin-google-analytics": "^9.4.4",
"@next/mdx": "^9.5.3",
"@next/plugin-google-analytics": "^9.5.3",
"@reactions/component": "^2.0.2",
"@zeit/fetch": "^6.0.0",
"@zeit/react-jsx-parser": "^2.0.0",
"async-sema": "^3.1.0",
"body-scroll-lock": "^3.0.1",
"body-scroll-lock": "^3.1.5",
"classnames": "^2.2.6",
"copy-to-clipboard": "^3.3.1",
"date-fns": "^2.12.0",
"date-fns": "^2.16.1",
"docsearch.js": "^2.6.3",
"framer-motion": "^1.11.1",
"gray-matter": "^4.0.2",
"imagemin-mozjpeg": "^9.0.0",
"imagemin-optipng": "^8.0.0",
"intersection-observer": "^0.10.0",
"isomorphic-unfetch": "^3.0.0",
"next": "^9.4.4",
"next-images": "^1.4.0",
"next-optimized-images": "^2.6.1",
"node-fetch": "^2.6.0",
"prismjs": "^1.20.0",
"next": "^9.5.3",
"next-images": "^1.5.0",
"next-optimized-images": "^2.6.2",
"node-fetch": "^2.6.1",
"prismjs": "^1.21.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-icons": "^3.9.0",
"react-icons": "^3.11.0",
"react-live": "^2.2.2",
"rehype-format": "^3.0.1",
"rehype-stringify": "^7.0.0",
"remark": "^12.0.0",
"remark": "^12.0.1",
"remark-autolink-headings": "^6.0.0",
"remark-emoji": "^2.1.0",
"remark-footnotes": "^1.0.0",
Expand All @@ -54,26 +54,26 @@
"remark-slug": "^6.0.0",
"remark-toc": "^7.0.0",
"remark-unwrap-images": "^2.0.0",
"scroll-into-view-if-needed": "^2.2.24",
"scroll-into-view-if-needed": "^2.2.26",
"semver-regex": "^3.1.1",
"unist-util-visit": "^2.0.2"
"unist-util-visit": "^2.0.3"
},
"devDependencies": {
"@babel/cli": "^7.10.4",
"@babel/core": "^7.10.4",
"@babel/plugin-transform-typescript": "^7.10.4",
"@babel/cli": "^7.11.6",
"@babel/core": "^7.11.6",
"@babel/plugin-transform-typescript": "^7.11.0",
"@babel/preset-react": "^7.10.4",
"@tailwindcss/ui": "^0.3.0",
"algoliasearch": "3.35.1",
"babel-preset-react-app": "^9.1.2",
"dotenv-load": "^2.0.0",
"github-slugger": "^1.3.0",
"md5": "^2.2.1",
"md5": "^2.3.0",
"mdast-util-to-string": "^1.1.0",
"postcss-preset-env": "^6.7.0",
"remark-parse": "^8.0.2",
"tailwindcss": "^1.4.6",
"unified": "^9.0.0",
"remark-parse": "^8.0.3",
"tailwindcss": "^1.8.10",
"unified": "^9.2.0",
"webp-loader": "^0.6.0"
},
"engines": {
Expand Down
27 changes: 16 additions & 11 deletions docs/src/components/DocsPageFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ function areEqual(prevProps, props) {
}

export const DocsPageFooter = React.memo(({ route, prevRoute, nextRoute }) => {
const editUrl = `${siteConfig.editUrl}${route?.editUrl || route?.path}`
const editUrl =
route?.editUrl || route?.path
? `${siteConfig.editUrl}${route?.editUrl || route?.path}`
: null

return (
<>
Expand Down Expand Up @@ -45,16 +48,18 @@ export const DocsPageFooter = React.memo(({ route, prevRoute, nextRoute }) => {
</div>
</div>

<div className="mb-8">
<a
href={editUrl}
target="_blank"
rel="noopener noreferrer"
className="text-gray-600 underline"
>
Edit this page on GitHub
</a>
</div>
{editUrl ? (
<div className="mb-8">
<a
href={editUrl}
target="_blank"
rel="noopener noreferrer"
className="text-gray-600 underline"
>
Edit this page on GitHub
</a>
</div>
) : null}

<div className="py-8 md:flex md:items-center md:py-8 border-t border-b">
<div className="font-semibold text-xl mr-4 text-center mb-4 md:mb-0 md:text-left">
Expand Down
6 changes: 3 additions & 3 deletions docs/src/components/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ export const Footer = props => {
</h4>
<ul className="mt-4">
<li>
<Link href="/docs/overview">
<Link href="/overview">
<a className="text-base leading-6 text-gray-500 hover:text-gray-900">
Docs
</a>
</Link>
</li>
<li className="mt-4">
<Link href="/docs/examples/simple">
<Link href="/examples/simple">
<a className="text-base leading-6 text-gray-500 hover:text-gray-900">
Examples
</a>
</Link>
</li>
<li className="mt-4">
<Link href="/docs/api">
<Link href="/api/useQuery">
<a className="text-base leading-6 text-gray-500 hover:text-gray-900">
API Reference
</a>
Expand Down
7 changes: 3 additions & 4 deletions docs/src/components/LayoutDocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ export const LayoutDocs = props => {
/>
<div className="block">
<>

<div className="container mx-auto pb-12 pt-6 content">
<div className="flex relative">
{!isMobile && (
Expand All @@ -89,7 +88,7 @@ export const LayoutDocs = props => {
)}

<div className={s['markdown'] + ' w-full docs'}>
<h1>{props.meta.title}</h1>
<h1 id="_top">{props.meta.title}</h1>
<MDXProvider components={MDXComponents}>
{props.children}
</MDXProvider>
Expand All @@ -107,11 +106,11 @@ export const LayoutDocs = props => {
width: 200,
}}
>
<div className="sticky top-24 ">
<div className="sticky top-24 overflow-y-auto">
<h4 className="font-semibold uppercase text-sm mb-2 mt-2 text-gray-500">
On this page
</h4>
<Toc />
<Toc title={props.meta.title} />
</div>
</div>
)}
Expand Down
4 changes: 2 additions & 2 deletions docs/src/components/Nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ export const Nav = () => (
<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">
<div className="flex space-x-4 md:space-x-8 text-sm md:text-base">
<div>
<Link href="/docs/overview">
<Link href="/overview">
<a className="leading-6 font-medium">Docs</a>
</Link>
</div>
<div>
<Link href="/docs/examples/simple">
<Link href="/examples/simple">
<a className="leading-6 font-medium">Examples</a>
</Link>
</div>
Expand Down
22 changes: 12 additions & 10 deletions docs/src/components/Toc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ import styles from './Toc.module.css'
const TOP_OFFSET = 100

function getHeaderAnchors() {
return Array.prototype.filter.call(
document.getElementsByClassName('anchor'),
function (testElement) {
return (
testElement.parentNode.nodeName === 'H2' ||
testElement.parentNode.nodeName === 'H3'
)
}
)
return [
...document.getElementsByTagName('H1'),
...[...document.getElementsByClassName('anchor')].filter(
el => el.parentNode.nodeName === 'H2' || el.parentNode.nodeName === 'H3'
),
].filter(Boolean)
}

function getHeaderDataFromAnchors(el) {
Expand All @@ -24,7 +21,7 @@ function getHeaderDataFromAnchors(el) {
}
}

export const Toc = () => {
export const Toc = ({ title }) => {
const headings = useTocHighlight(
styles.contents__link,
styles['contents__link--active'],
Expand All @@ -36,6 +33,11 @@ export const Toc = () => {

return (
<ul className="space-y-3">
<li className="text-sm">
<a className={styles.contents__link} href="#_top">
{title}
</a>
</li>
{headings &&
headings.length > 0 &&
headings.map((h, i) =>
Expand Down
Loading

1 comment on commit ac342e2

@vercel
Copy link

@vercel vercel bot commented on ac342e2 Dec 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.