Devtools for React Query. react-query-devtools
$ npm i --save react-query-devtools
# or
$ yarn add react-query-devtools
By default, React Query Devtools are not imported and used when process.env.NODE_ENV === 'production'
, so you don’t need to worry about excluding them during a production build.
If you want to use the devtools in production, you can manually import them (preferably asynchronously code-split) by importing the dist/react-query-devtools.production.min.js
file directly.
Floating Mode will mount the devtools as a fixed, floating element in your app and provide a toggle in the corner of the screen you can use to show and hide the devtools. This toggle state will be stored and remembered in localStorage across reloads.
Place the following code as high in your React app as you possibly can. The close it is to the root of the page, the better it will work!
import { ReactQueryDevtools } from 'react-query-devtools'
function App() {
return (
<>
{/* The rest of your application */}
<ReactQueryDevtools initialIsOpen={false} />
</>
)
}
initialIsOpen: Boolean
true
if you want the dev tools to default to being openEmbedded Mode will embed the devtools as a regular component in your application. You can style it however you’d like after that!
import { ReactQueryDevtoolsPanel } from 'react-query-devtools'
function App() {
return (
<>
{/* The rest of your application */}
<ReactQueryDevtoolsPanel style={styles} className={className} />
</>
)
}
style: StyleObject
className: string
Author: tannerlinsley
Live Demo: https://codesandbox.io/s/github/tannerlinsley/react-query/tree/master/examples/sandbox
GitHub: https://github.com/tannerlinsley/react-query-devtools
#reactjs #javascript #Query