Skip to content

Commit

Permalink
feat: Add TS Query v5 to Gazebo (#3415)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholas-codecov authored Oct 21, 2024
1 parent ab1c552 commit a4a1667
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 7 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"@stripe/react-stripe-js": "^2.7.1",
"@stripe/stripe-js": "^3.4.0",
"@tanstack/react-query": "^4.29.5",
"@tanstack/react-queryV5": "npm:@tanstack/react-query@^5.59.15",
"@tanstack/react-table": "^8.9.1",
"@tanstack/react-virtual": "^3.8.1",
"classnames": "^2.3.1",
Expand Down
41 changes: 34 additions & 7 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import * as Sentry from '@sentry/react'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import {
QueryClientProvider as QueryClientProviderV5,
QueryClient as QueryClientV5,
} from '@tanstack/react-queryV5'
import { createBrowserHistory } from 'history'
import React from 'react'
import { createRoot } from 'react-dom/client'
Expand Down Expand Up @@ -57,6 +61,27 @@ const queryClient = new QueryClient({
},
})

const queryClientV5 = new QueryClientV5({
defaultOptions: {
queries: {
retry: (failureCount, error) => {
// Do not retry if the response status is 429
if (
typeof error === 'object' &&
error !== null &&
'status' in error &&
error.status === TOO_MANY_REQUESTS_ERROR_CODE
) {
return false
}
// Otherwise, retry up to 3 times
return failureCount < 3
},
refetchOnWindowFocus: false,
},
},
})

const domNode = document.getElementById('root')

if (!domNode) {
Expand All @@ -68,13 +93,15 @@ const root = createRoot(domNode)
root.render(
<React.StrictMode>
<ErrorBoundary>
<QueryClientProvider client={queryClient}>
<Router history={history}>
<CompatRouter>
<ProfiledApp />
</CompatRouter>
</Router>
</QueryClientProvider>
<QueryClientProviderV5 client={queryClientV5}>
<QueryClientProvider client={queryClient}>
<Router history={history}>
<CompatRouter>
<ProfiledApp />
</CompatRouter>
</Router>
</QueryClientProvider>
</QueryClientProviderV5>
</ErrorBoundary>
</React.StrictMode>
)
19 changes: 19 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6456,6 +6456,13 @@ __metadata:
languageName: node
linkType: hard

"@tanstack/query-core@npm:5.59.13":
version: 5.59.13
resolution: "@tanstack/query-core@npm:5.59.13"
checksum: 10c0/57b43a9c1599b99055195fa83db80ddc7e00996244e9b73de5afa6bb8b0b489ee344ca5bcd660ccb9a6e4d2c01ef5dab42acd2e30ffa2b96d0335b3facb84707
languageName: node
linkType: hard

"@tanstack/react-query-devtools@npm:^4.29.6":
version: 4.36.1
resolution: "@tanstack/react-query-devtools@npm:4.36.1"
Expand Down Expand Up @@ -6490,6 +6497,17 @@ __metadata:
languageName: node
linkType: hard

"@tanstack/react-queryV5@npm:@tanstack/react-query@^5.59.15":
version: 5.59.15
resolution: "@tanstack/react-query@npm:5.59.15"
dependencies:
"@tanstack/query-core": "npm:5.59.13"
peerDependencies:
react: ^18 || ^19
checksum: 10c0/7b697eee85ed40efb82b6609434e2580405a3c32844365a8bb876b354e3068b21e0fa4c8ed0f5a06af45dc68373f39873b046f104975a31204d9288e03bba0f5
languageName: node
linkType: hard

"@tanstack/react-table@npm:^8.9.1":
version: 8.19.3
resolution: "@tanstack/react-table@npm:8.19.3"
Expand Down Expand Up @@ -12580,6 +12598,7 @@ __metadata:
"@tanstack/eslint-plugin-query": "npm:^4.29.4"
"@tanstack/react-query": "npm:^4.29.5"
"@tanstack/react-query-devtools": "npm:^4.29.6"
"@tanstack/react-queryV5": "npm:@tanstack/react-query@^5.59.15"
"@tanstack/react-table": "npm:^8.9.1"
"@tanstack/react-virtual": "npm:^3.8.1"
"@testing-library/dom": "npm:10.3.2"
Expand Down

0 comments on commit a4a1667

Please sign in to comment.