Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix suspense example #3619

Closed
wants to merge 91 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
b84681f
v4 alpha (#3060)
TkDodo Dec 7, 2021
66c9711
Merge remote-tracking branch 'react-query/master' into alpha
TkDodo Dec 10, 2021
14da2c8
Merge remote-tracking branch 'react-query/master' into alpha
TkDodo Dec 10, 2021
1247d7b
refactor(core): refactor internals from classes to a functions (#3066)
TkDodo Dec 10, 2021
942805f
feat(useQueries): v4 api to take an object as input (#3071)
babycourageous Dec 10, 2021
95922e7
refactor(tests): adapt useInfiniteQuery test
TkDodo Dec 10, 2021
e200bf7
refactor(tests): adapt useInfiniteQuery test
TkDodo Dec 10, 2021
3722b6b
refactor: use a set for tracked props (#3085)
TkDodo Dec 11, 2021
5e2f2c2
chore: update tooling (#3086)
TkDodo Dec 11, 2021
c50b630
fix(queryObserver): defer tracking of error prop when useErrorBoundar…
TkDodo Dec 11, 2021
8cf612e
Merge remote-tracking branch 'react-query/master' into alpha
TkDodo Dec 14, 2021
84b06ec
docs: Update migrating-to-react-query-4.md (#3096)
afertil Dec 15, 2021
c53e5ed
Merge remote-tracking branch 'react-query/master' into alpha
TkDodo Dec 16, 2021
9a20452
refactor: remove logging in prod mode (#3103)
TkDodo Dec 16, 2021
250c654
Merge remote-tracking branch 'react-query/master' into alpha
TkDodo Dec 28, 2021
e21ef6c
refactor: remove cancel method as it no longer exists (#3142)
TkDodo Dec 28, 2021
047d6cf
refactor: remove unused query.setDefaultOptions
TkDodo Dec 31, 2021
1abb371
feat(persistQueryClient): improve persist controls (#3141)
jonathanstanley Jan 14, 2022
47bf076
Merge remote-tracking branch 'react-query/master' into alpha
TkDodo Jan 21, 2022
4afd0c3
docs: clarify caching behavior (#3221)
aryzing Jan 22, 2022
d4b6afc
Merge remote-tracking branch 'react-query/master' into alpha
TkDodo Jan 23, 2022
c0fc916
fix(core): do not refetch disabled queries (#3223)
TkDodo Jan 23, 2022
52ad9cc
refactor(mutation): remove mutation.cancel (#3225)
TkDodo Feb 6, 2022
e90e7f8
refactor(queryClient): add dev warning with queryDefaults (#3249)
GLabat Feb 6, 2022
239d66c
Merge remote-tracking branch 'react-query/master' into alpha
TkDodo Feb 6, 2022
2b5c337
chore: fix silent merge conflicts
TkDodo Feb 6, 2022
7ee784f
feat: Bail out if query data undefined (#3271)
phatmann Feb 9, 2022
6ec6811
chore: add a test to ensure that callback on .mutate are only called …
TkDodo Feb 9, 2022
7064c69
docs: Document compression use case for `createWebStoragePersister` (…
hverlin Feb 10, 2022
00d0c52
refactor: inline / remove some functions for size improvements (#3289)
TkDodo Feb 12, 2022
0981378
Merge remote-tracking branch 'react-query/master' into alpha
TkDodo Feb 12, 2022
293e5e9
refactor: do not log undefined query data warning to the console
TkDodo Feb 14, 2022
ada0e34
feat: Version 4 codemods (#3195)
balazsmatepetro Feb 18, 2022
aa853d8
Merge remote-tracking branch 'react-query/master' into alpha
TkDodo Feb 20, 2022
fe98d53
feat: remove idle state (#3302)
TkDodo Feb 24, 2022
315f0cf
feat(*): add optional logger prop to QueryClient config (#3246)
anilanar Feb 26, 2022
4253ff3
refactor: turn off error logging in tests
TkDodo Feb 26, 2022
61fd539
docs(examples): fix optimistic-updates-typescript example
TkDodo Feb 26, 2022
ead3d69
chore(bundling): bundle for modern browsers (#3342)
TkDodo Feb 26, 2022
f53d8b1
chore: eslint no-unnecessary-condition (#3344)
TkDodo Feb 26, 2022
f426899
fix(mutations): avoid infinite loading states if callbacks return an …
TkDodo Feb 26, 2022
02fd793
fix(react-native): bring back check for window.addEventListener (#3345)
TkDodo Feb 27, 2022
9d260e7
refactor(queryObserver): get rid of double-defaulting of options in g…
TkDodo Feb 28, 2022
338da80
fix(createAsyncStoragePersister): persistClient respects throttleTime…
huanguolin Mar 1, 2022
154b5c1
docs: update persistQueryClient.md with Persister docs (#3356)
jonathanstanley Mar 3, 2022
d07e0f8
Merge remote-tracking branch 'react-query/master' into alpha
TkDodo Mar 3, 2022
49f2923
docs: add Offline React Query post (#3320)
MostafaNawara Mar 3, 2022
bc7263d
docs: multi-line code snippet for layout on mobile
TkDodo Mar 5, 2022
fee4a14
fix(mutations): allow passing a function to useErrorBoundary (#3390)
TkDodo Mar 13, 2022
1b91f3f
Merge remote-tracking branch 'react-query/master' into alpha
TkDodo Mar 13, 2022
cba4503
docs: idle state is removed
TkDodo Mar 23, 2022
f31e1ed
feat: Support the ability to provide a context (#2548)
blackarctic Mar 23, 2022
ba78256
feat(persistQueryClient): PersistQueryClientProvider (#3248)
TkDodo Mar 24, 2022
21dd633
Merge remote-tracking branch 'tannerlinsley/master' into alpha
TkDodo Mar 24, 2022
3ed5e48
feat(cacheTime): default cacheTime to Infinity for SSR (#3377)
JacobLey Mar 24, 2022
6e4ebec
docs(examples): fix offline example (#3463)
TkDodo Apr 2, 2022
49704c7
Merge remote-tracking branch 'tannerlinsley/master' into alpha
TkDodo Apr 2, 2022
39a213e
fix(persistQueryClient): subscribe to both QueryCache and MutationCache
TkDodo Apr 2, 2022
4d753c0
feat: add support for react 18
TkDodo Apr 2, 2022
f58eaf9
chore: release beta docs
TkDodo Apr 2, 2022
231b543
docs: fix suspense example (#3458)
nikasepiskveradze Apr 2, 2022
aa723a0
docs(examples): update examples to use react18 (#3466)
TkDodo Apr 3, 2022
de0f9d8
docs(examples): make offline example a bit better
TkDodo Apr 8, 2022
13dbb27
docs(QueryClient): fix indentation
TkDodo Apr 8, 2022
58a9fe9
fix(types): use react 18 types (#3482)
TkDodo Apr 8, 2022
5562cfa
fix(types): fix promise inference in useQueries (#3493)
artysidorenko Apr 11, 2022
7bba5a9
docs(v4): update context example in v4 migration guide
TkDodo Apr 16, 2022
35dfe5f
merge branch master into beta
TkDodo Apr 21, 2022
af850e5
test: stabilize new test
TkDodo Apr 21, 2022
a8ddd9b
test: stabilize some more tests
TkDodo Apr 21, 2022
9e23e7a
fix(persistQueryClient): rename isHydrating to isRestoring (#3512)
TkDodo Apr 21, 2022
1af25c6
docs: fix offline example
TkDodo Apr 24, 2022
3fabd41
fix: ESM compliant bundling (#3521)
sachinraja Apr 26, 2022
fdbc002
fix: Use fully-specified path to import use-sync-external-store/shim …
latin-1 Apr 26, 2022
6379654
fix: move usage of React Context out of core package (#3578)
TkDodo May 7, 2022
5f80b09
fix: type issue when void or undefined is returned from query functio…
yss14 May 8, 2022
e01a7bb
fix: uSES import for react-native / esm (#3601)
hirbod May 12, 2022
7d3f7a2
fix(query): updating with setQueryData should not affect fetchStatus …
TkDodo May 14, 2022
0085137
chore: bump uSES to 1.1.0 (#3614)
hirbod May 14, 2022
35a40ec
fix(queryClient): make sure that setQueryData can return undefined fr…
TkDodo May 14, 2022
1909cb9
docs: point offline example to /beta
TkDodo May 21, 2022
34afdde
feat(persistQueryClient): persist error handling (#3556)
TkDodo May 21, 2022
6f2febc
fix(devtools): Fix expand button styling (#3544)
Liam-Tait Apr 22, 2022
a804fcc
feat: expose errorUpdateCount on useQuery (#3532)
OmerCohenAviv Apr 22, 2022
9657a41
test(useQuery): add test for errorUpdateCount (#3547)
OmerCohenAviv Apr 22, 2022
157e994
docs: Remove react-native-appstate-hook (#3574)
bangseongbeom May 1, 2022
d882161
fix(queryObserver): cache select errors (#3554)
TkDodo May 1, 2022
dcc6008
feat(devtools): the react query logo can now close the devtools (#3577)
himankpathak May 8, 2022
41782f2
fix: :bug: Remove missing dependency prettier from eslint config
MMMikeM May 17, 2022
ab70e59
chore: :arrow_up: Updated non-breaking dependencies and modified pack…
MMMikeM May 17, 2022
2dc0dd9
refactor: :fire: Clean up comments
MMMikeM May 17, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 9 additions & 11 deletions .babelrc.js
@@ -1,33 +1,31 @@
const { NODE_ENV, BABEL_ENV } = process.env
const cjs = NODE_ENV === 'test' || BABEL_ENV === 'commonjs'
const es = BABEL_ENV === 'es'
const loose = true

module.exports = {
presets: [
[
'@babel/env',
'@babel/preset-env',
{
loose,
modules: false,
exclude: ['@babel/plugin-transform-regenerator'],
exclude: [
'@babel/plugin-transform-regenerator',
'@babel/plugin-transform-parameters',
],
},
],
'@babel/preset-typescript',
'@babel/react',
],
plugins: [
[
'const-enum',
{
transform: 'constObject',
},
],
'babel-plugin-transform-async-to-promises',
cjs && ['@babel/transform-modules-commonjs', { loose }],
[
es && ['babel-plugin-add-import-extension', { extension: 'mjs' }],
// no runtime for umd builds
BABEL_ENV && [
'@babel/transform-runtime',
{
useESModules: !cjs,
version: require('./package.json').dependencies[
'@babel/runtime'
].replace(/^[^0-9]*/, ''),
Expand Down
12 changes: 5 additions & 7 deletions .browserslistrc
@@ -1,9 +1,7 @@
# Browsers we support
> 0.5%
Chrome >= 73
ChromeAndroid >= 75
Firefox >= 67
Edge >= 17
IE 11
Safari >= 12.1
iOS >= 11.3
Firefox >= 78
Edge >= 79
Safari >= 12.0
iOS >= 12.0
opera >= 53
15 changes: 15 additions & 0 deletions .eslintrc
Expand Up @@ -12,6 +12,7 @@
"es6": true
},
"parserOptions": {
"project": "./tsconfig.json",
"sourceType": "module"
},
"rules": {
Expand All @@ -22,6 +23,7 @@
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unnecessary-condition": "error",
"@typescript-eslint/no-inferrable-types": [
"error",
{
Expand All @@ -32,6 +34,19 @@
"import/no-cycle": "error",
"import/no-unresolved": ["error", { "ignore": ["react-query"] }],
"import/no-unused-modules": ["off", { "unusedExports": true }],
"import/no-restricted-paths": [
"error",
{
"zones": [
{ "target": "src/core", "from": "src/broadcastQueryClient-experimental" },
{ "target": "src/core", "from": "src/createAsyncStoragePersister" },
{ "target": "src/core", "from": "src/createWebStoragePersister" },
{ "target": "src/core", "from": "src/devtools" },
{ "target": "src/core", "from": "src/persistQueryClient" },
{ "target": "src/core", "from": "src/reactjs" }
]
}
],
"no-redeclare": "off"
}
}
12 changes: 8 additions & 4 deletions .github/workflows/test-and-publish.yml
Expand Up @@ -5,18 +5,20 @@ on:
branches:
- 'master'
- 'next'
- 'alpha'
- 'beta'
- '1.x'
- '2.x'
pull_request:

jobs:
test:
name: 'Node ${{ matrix.node }}'
name: 'Node ${{ matrix.node }}, React ${{ matrix.react }}'
runs-on: ubuntu-latest
strategy:
matrix:
node: [12, 14, 16]
node: [14, 16]
react: [17, 18]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
Expand All @@ -25,8 +27,10 @@ jobs:
- name: Install dependencies
uses: bahmutov/npm-install@v1
- run: yarn test:ci
env:
REACTJS_VERSION: ${{ matrix.react }}
- run: yarn test:size
if: matrix.node == '16'
if: matrix.node == '16' && matrix.react == '18'
env:
BUNDLEWATCH_GITHUB_TOKEN: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
- name: Upload coverage to Codecov
Expand All @@ -36,7 +40,7 @@ jobs:
name: 'Publish Module to NPM'
needs: test
# publish only when merged in master on original repo, not on PR
if: github.repository == 'tannerlinsley/react-query' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/next' || github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/1.x' || github.ref == 'refs/heads/2.x')
if: github.repository == 'tannerlinsley/react-query' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/next' || github.ref == 'refs/heads/alpha' || github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/1.x' || github.ref == 'refs/heads/2.x')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
8 changes: 0 additions & 8 deletions .vscode/settings.json

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -94,4 +94,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 3 -->
<!-- Force 4 -->
1 change: 1 addition & 0 deletions broadcastQueryClient-experimental/index.d.ts
@@ -0,0 +1 @@
export * from '../lib/broadcastQueryClient-experimental'
1 change: 1 addition & 0 deletions broadcastQueryClient-experimental/index.js
@@ -0,0 +1 @@
module.exports = require('../lib/broadcastQueryClient-experimental/index')
3 changes: 3 additions & 0 deletions codemods/jest.config.js
@@ -0,0 +1,3 @@
module.exports = {
testMatch: ['<rootDir>/**/*.test.js'],
}
94 changes: 94 additions & 0 deletions codemods/v4/__testfixtures__/default-import.input.tsx
@@ -0,0 +1,94 @@
import * as React from 'react'
import {
QueryCache,
QueryClient,
useInfiniteQuery,
useIsFetching,
useIsMutating,
useMutation,
useQueries,
useQuery,
useQueryClient,
} from 'react-query'

export const Examples = () => {
useQuery('todos')
useInfiniteQuery('todos')
useMutation('todos')
useIsFetching('todos')
useIsMutating('todos')
useQueries([query1, query2])
// QueryClient methods
// --- Instantiated hook call.
const queryClient = useQueryClient()
queryClient.getMutationDefaults('todos')
queryClient.getQueriesData('todos')
queryClient.getQueryData('todos')
queryClient.getQueryDefaults('todos')
queryClient.getQueryState('todos')
queryClient.isFetching('todos')
queryClient.setMutationDefaults('todos', { mutationFn: async () => null })
queryClient.setQueriesData('todos', () => null)
queryClient.setQueryData('todos', () => null)
queryClient.setQueryDefaults('todos', { queryFn: async () => null })
queryClient.cancelQueries('todos')
queryClient.fetchInfiniteQuery('todos')
queryClient.fetchQuery('todos')
queryClient.invalidateQueries('todos')
queryClient.prefetchInfiniteQuery('todos')
queryClient.prefetchQuery('todos')
queryClient.refetchQueries('todos')
queryClient.removeQueries('todos')
queryClient.resetQueries('todos')
// --- Direct hook call.
useQueryClient().getMutationDefaults('todos')
useQueryClient().getQueriesData('todos')
useQueryClient().getQueryData('todos')
useQueryClient().getQueryDefaults('todos')
useQueryClient().getQueryState('todos')
useQueryClient().isFetching('todos')
useQueryClient().setMutationDefaults('todos', {
mutationFn: async () => null,
})
useQueryClient().setQueriesData('todos', () => null)
useQueryClient().setQueryData('todos', () => null)
useQueryClient().setQueryDefaults('todos', { queryFn: async () => null })
useQueryClient().cancelQueries('todos')
useQueryClient().fetchInfiniteQuery('todos')
useQueryClient().fetchQuery('todos')
useQueryClient().invalidateQueries('todos')
useQueryClient().prefetchInfiniteQuery('todos')
useQueryClient().prefetchQuery('todos')
useQueryClient().refetchQueries('todos')
useQueryClient().removeQueries('todos')
useQueryClient().resetQueries('todos')
// QueryCache
// --- NewExpression
const queryCache1 = new QueryCache({
onError: (error) => console.log(error),
onSuccess: (success) => console.log(success)
})
queryCache1.find('todos')
queryCache1.findAll('todos')
// --- Instantiated hook call.
const queryClient1 = useQueryClient()
queryClient1.getQueryCache().find('todos')
queryClient1.getQueryCache().findAll('todos')
//
const queryClient2 = new QueryClient({})
queryClient2.getQueryCache().find('todos')
queryClient2.getQueryCache().findAll('todos')
//
const queryCache2 = queryClient1.getQueryCache()
queryCache2.find('todos')
queryCache2.findAll('todos')
// --- Direct hook call.
useQueryClient().getQueryCache().find('todos')
useQueryClient().getQueryCache().findAll('todos')
//
const queryCache3 = useQueryClient().getQueryCache()
queryCache3.find('todos')
queryCache3.findAll('todos')

return <div>Example Component</div>
}
96 changes: 96 additions & 0 deletions codemods/v4/__testfixtures__/default-import.output.tsx
@@ -0,0 +1,96 @@
import * as React from 'react'
import {
QueryCache,
QueryClient,
useInfiniteQuery,
useIsFetching,
useIsMutating,
useMutation,
useQueries,
useQuery,
useQueryClient,
} from 'react-query'

export const Examples = () => {
useQuery(['todos'])
useInfiniteQuery(['todos'])
useMutation(['todos'])
useIsFetching(['todos'])
useIsMutating(['todos'])
useQueries({
queries: [query1, query2]
})
// QueryClient methods
// --- Instantiated hook call.
const queryClient = useQueryClient()
queryClient.getMutationDefaults(['todos'])
queryClient.getQueriesData(['todos'])
queryClient.getQueryData(['todos'])
queryClient.getQueryDefaults(['todos'])
queryClient.getQueryState(['todos'])
queryClient.isFetching(['todos'])
queryClient.setMutationDefaults(['todos'], { mutationFn: async () => null })
queryClient.setQueriesData(['todos'], () => null)
queryClient.setQueryData(['todos'], () => null)
queryClient.setQueryDefaults(['todos'], { queryFn: async () => null })
queryClient.cancelQueries(['todos'])
queryClient.fetchInfiniteQuery(['todos'])
queryClient.fetchQuery(['todos'])
queryClient.invalidateQueries(['todos'])
queryClient.prefetchInfiniteQuery(['todos'])
queryClient.prefetchQuery(['todos'])
queryClient.refetchQueries(['todos'])
queryClient.removeQueries(['todos'])
queryClient.resetQueries(['todos'])
// --- Direct hook call.
useQueryClient().getMutationDefaults(['todos'])
useQueryClient().getQueriesData(['todos'])
useQueryClient().getQueryData(['todos'])
useQueryClient().getQueryDefaults(['todos'])
useQueryClient().getQueryState(['todos'])
useQueryClient().isFetching(['todos'])
useQueryClient().setMutationDefaults(['todos'], {
mutationFn: async () => null,
})
useQueryClient().setQueriesData(['todos'], () => null)
useQueryClient().setQueryData(['todos'], () => null)
useQueryClient().setQueryDefaults(['todos'], { queryFn: async () => null })
useQueryClient().cancelQueries(['todos'])
useQueryClient().fetchInfiniteQuery(['todos'])
useQueryClient().fetchQuery(['todos'])
useQueryClient().invalidateQueries(['todos'])
useQueryClient().prefetchInfiniteQuery(['todos'])
useQueryClient().prefetchQuery(['todos'])
useQueryClient().refetchQueries(['todos'])
useQueryClient().removeQueries(['todos'])
useQueryClient().resetQueries(['todos'])
// QueryCache
// --- NewExpression
const queryCache1 = new QueryCache({
onError: (error) => console.log(error),
onSuccess: (success) => console.log(success)
})
queryCache1.find(['todos'])
queryCache1.findAll(['todos'])
// --- Instantiated hook call.
const queryClient1 = useQueryClient()
queryClient1.getQueryCache().find(['todos'])
queryClient1.getQueryCache().findAll(['todos'])
//
const queryClient2 = new QueryClient({})
queryClient2.getQueryCache().find(['todos'])
queryClient2.getQueryCache().findAll(['todos'])
//
const queryCache2 = queryClient1.getQueryCache()
queryCache2.find(['todos'])
queryCache2.findAll(['todos'])
// --- Direct hook call.
useQueryClient().getQueryCache().find(['todos'])
useQueryClient().getQueryCache().findAll(['todos'])
//
const queryCache3 = useQueryClient().getQueryCache()
queryCache3.find(['todos'])
queryCache3.findAll(['todos'])

return <div>Example Component</div>
}