File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -87,3 +87,47 @@ Use these options to style the dev tools.
87
87
- The standard React style object used to style a component with inline styles
88
88
- ` className: string `
89
89
- The standard React className property used to style a component with classes
90
+
91
+ ## Devtools in production
92
+
93
+ Devtools are excluded in production builds. However, it might be desirable to lazy load the devtools in production:
94
+
95
+ ``` tsx
96
+ import * as React from ' react'
97
+ import { QueryClient , QueryClientProvider } from ' @tanstack/react-query'
98
+ import { ReactQueryDevtools } from ' @tanstack/react-query-devtools'
99
+ import { Example } from ' ./Example'
100
+
101
+ const queryClient = new QueryClient ()
102
+
103
+ const ReactQueryDevtoolsProduction = React .lazy (() =>
104
+ import (' @tanstack/react-query-devtools/build/lib/index.prod.js' ).then (d => ({
105
+ default: d .ReactQueryDevtools
106
+ }))
107
+ )
108
+
109
+ function App() {
110
+ const [showDevtools, setShowDevtools] = React .useState (false )
111
+
112
+ React .useEffect (() => {
113
+ // @ts-ignore
114
+ window .toggleDevtools = () => setShowDevtools (old => ! old )
115
+ }, [])
116
+
117
+ return (
118
+ <QueryClientProvider client = { queryClient } >
119
+ <Example />
120
+ <ReactQueryDevtools initialIsOpen />
121
+ { showDevtools && (
122
+ <React.Suspense fallback = { null } >
123
+ <ReactQueryDevtoolsProduction />
124
+ </React.Suspense >
125
+ )}
126
+ </QueryClientProvider >
127
+ );
128
+ }
129
+
130
+ export default App
131
+ ```
132
+
133
+ With this, calling ` window.toggleDevtools() ` will download the devtools bundle and show them.
You can’t perform that action at this time.
0 commit comments