-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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(react-query): move away of uSES #8434
Open
KATT
wants to merge
67
commits into
TanStack:main
Choose a base branch
from
KATT:issues/8384
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 59 commits
Commits
Show all changes
67 commits
Select commit
Hold shift + click to select a range
7d3fccc
wip
KATT bc36411
wip
KATT 63c548c
wip
KATT 3ed5349
ci: apply automated fixes
autofix-ci[bot] 784cb83
wip
KATT fb21469
wip
KATT a7ba6bc
kinda works
KATT b6917d2
apparently this fixes stuff
KATT 71ccdcf
ok works
KATT 0faec03
ci: apply automated fixes
autofix-ci[bot] 16e9c59
bump
KATT 510bcbe
wip
KATT 76fd305
Merge branch 'issues/8384' of github.com:KATT/react-query into issues…
KATT f035539
ci: apply automated fixes
autofix-ci[bot] ec4d91e
uhm
KATT bd25f47
Merge branch 'issues/8384' of github.com:KATT/react-query into issues…
KATT 3002562
ci: apply automated fixes
autofix-ci[bot] 61d9be3
wip
KATT 46d145c
wip
KATT 201169a
reset
KATT 3685c95
reset
KATT a1890ed
hi
KATT 123d6e4
ci: apply automated fixes
autofix-ci[bot] cc5d27f
wip
KATT f5c1e5d
Merge branch 'issues/8384' of github.com:KATT/react-query into issues…
KATT ab24be3
act fix
KATT 27d348c
delete lib
KATT e2dca98
cleanup
KATT c0d3680
meep
KATT 77f4616
less diff
KATT a1e2dd8
less diff
KATT 50dfe93
cool
KATT 3f6748a
mkay
KATT 6e4a559
ci: apply automated fixes
autofix-ci[bot] 2649b87
fucking lint
KATT d878172
revert
KATT 4b9c5d8
test: startTransition
TkDodo 19f7230
Merge branch 'feature/transition-tests' of github.com:TanStack/query …
KATT 38b8864
fix test
KATT 84dffdc
rm dep array
KATT a728d6b
mkay
KATT 58f0f77
Merge branch 'main' into issues/8384
KATT 984fa4b
failing test
KATT cfdf512
Merge branch 'issues/8384' of github.com:KATT/react-query into issues…
KATT ed313f7
mkay better test
KATT dcf16f2
might revert this later
KATT 60f6736
prettier
KATT 5a97880
Revert "might revert this later"
KATT aba6e7f
wait
KATT b5d30af
mkay
KATT e6a7d00
vscode helps
KATT 847e7da
why doesn’t this failllll
KATT cb449e0
org
KATT 4a5296c
add transition
KATT c0d341e
tweak
KATT 02d9727
fix
KATT 442c4d5
mkay
KATT f93377b
pendy
KATT 76bfacf
revert useIsFetching etc etc
KATT efed3ff
does this fail?
KATT 5a1358e
idk
KATT 30e819b
wip
KATT 83dddf0
fix test
KATT 7e7d55c
ok
KATT 7df5d81
test: add test case for 8249
TkDodo 9096707
rest: re-order describe blocks to avoid "act not available in environ…
TkDodo 9797e93
Merge branch 'main' into issues/8384
TkDodo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.formatOnSave": true | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": ["plugin:react/jsx-runtime", "plugin:react-hooks/recommended"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
pnpm-lock.yaml | ||
yarn.lock | ||
package-lock.json | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Example | ||
|
||
To run this example: | ||
|
||
- `pnpm install` | ||
- `pnpm dev` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="shortcut icon" type="image/svg+xml" href="/emblem-light.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="theme-color" content="#000000" /> | ||
|
||
<title>TanStack Query React Suspense Example App</title> | ||
</head> | ||
<body> | ||
<noscript>You need to enable JavaScript to run this app.</noscript> | ||
<div id="root"></div> | ||
<script type="module" src="/src/index.tsx"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "@tanstack/query-example-react-transition", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"preview": "vite preview" | ||
}, | ||
"dependencies": { | ||
"@tanstack/react-query": "^5.62.8", | ||
"@tanstack/react-query-devtools": "^5.62.8", | ||
"react": "^19.0.0", | ||
"react-dom": "^19.0.0" | ||
}, | ||
"devDependencies": { | ||
"@vitejs/plugin-react": "^4.3.3", | ||
"typescript": "5.7.2", | ||
"vite": "^5.3.5" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import { | ||
QueryClient, | ||
QueryClientProvider, | ||
useQuery, | ||
} from '@tanstack/react-query' | ||
import { Suspense, use, useState, useTransition } from 'react' | ||
import ReactDOM from 'react-dom/client' | ||
|
||
const Example1 = ({ value }: { value: number }) => { | ||
const { isFetching, promise } = useQuery({ | ||
queryKey: ['1' + value], | ||
queryFn: async () => { | ||
await new Promise((resolve) => setTimeout(resolve, 1000)) | ||
return '1' + value | ||
}, | ||
}) | ||
const data = use(promise) | ||
|
||
return ( | ||
<div> | ||
{data} {isFetching ? 'fetching' : null} | ||
</div> | ||
) | ||
} | ||
|
||
const Example2 = ({ value }: { value: number }) => { | ||
const { promise, isFetching } = useQuery({ | ||
queryKey: ['2' + value], | ||
queryFn: async () => { | ||
await new Promise((resolve) => setTimeout(resolve, 2000)) | ||
return '2' + value | ||
}, | ||
// placeholderData: keepPreviousData, | ||
}) | ||
|
||
const data = use(promise) | ||
|
||
return ( | ||
<div> | ||
{data} {isFetching ? 'fetching' : null} | ||
</div> | ||
) | ||
} | ||
|
||
const SuspenseBoundary = () => { | ||
const [state, setState] = useState(-1) | ||
const [isPending, startTransition] = useTransition() | ||
|
||
return ( | ||
<div> | ||
<h1>Change state with transition</h1> | ||
<div> | ||
<button | ||
onClick={() => | ||
startTransition(() => { | ||
setState((s) => s - 1) | ||
}) | ||
} | ||
> | ||
Decrease | ||
</button> | ||
</div> | ||
<h2>State:</h2> | ||
<ul> | ||
<li>last state value: {state}</li> | ||
<li> | ||
transition state: {isPending ? <strong>pending</strong> : 'idle'} | ||
</li> | ||
</ul> | ||
<h2>2. 1 Suspense + startTransition</h2> | ||
<Suspense fallback="fallback 1"> | ||
<Example1 value={state}></Example1> | ||
</Suspense> | ||
<h2>2.2 Suspense + startTransition</h2> | ||
<Suspense fallback="fallback 2"> | ||
<Example2 value={state}></Example2> | ||
</Suspense> | ||
</div> | ||
) | ||
} | ||
|
||
const queryClient = new QueryClient({ | ||
defaultOptions: { | ||
queries: { | ||
experimental_prefetchInRender: true, | ||
staleTime: 10 * 1000, | ||
}, | ||
}, | ||
}) | ||
|
||
const App = () => { | ||
return ( | ||
<div> | ||
<QueryClientProvider client={queryClient}> | ||
<SuspenseBoundary /> | ||
</QueryClientProvider> | ||
</div> | ||
) | ||
} | ||
|
||
const rootElement = document.getElementById('root') as HTMLElement | ||
ReactDOM.createRoot(rootElement).render(<App />) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2020", | ||
"useDefineForClassFields": true, | ||
"lib": ["ES2020", "DOM", "DOM.Iterable"], | ||
"module": "ESNext", | ||
"skipLibCheck": true, | ||
|
||
/* Bundler mode */ | ||
"moduleResolution": "Bundler", | ||
"allowImportingTsExtensions": true, | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"noEmit": true, | ||
"jsx": "react-jsx", | ||
|
||
/* Linting */ | ||
"strict": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noFallthroughCasesInSwitch": true | ||
}, | ||
"include": ["src", "eslint.config.js"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { defineConfig } from 'vite' | ||
import react from '@vitejs/plugin-react' | ||
|
||
export default defineConfig({ | ||
plugins: [react()], | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to remove this, but it helps me as a contributor - I have a bunch of settings in trpc https://github.com/trpc/trpc/tree/next/.vscode