Skip to content

Commit 26db5a4

Browse files
committed
feat: devtools are now native to the core repo/npm-package
1 parent 963c3f6 commit 26db5a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1574
-209
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [React Tabl
3939
- Load-More + Infinite Scroll Queries w/ Scroll Recovery
4040
- Request Cancellation
4141
- [React Suspense](https://reactjs.org/docs/concurrent-mode-suspense.html) + Fetch-As-You-Render Query Prefetching
42-
- [Dedicated Devtools (React Query Devtools)](https://github.com/tannerlinsley/react-query-devtools)
42+
- [Dedicated Devtools
4343
- <a href="https://bundlephobia.com/result?p=react-query@latest" target="\_parent">
4444
<img alt="" src="https://badgen.net/bundlephobia/minzip/react-query@latest" />
4545
</a> (depending on features imported)

devtools/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"internal": true,
3+
"main": "../lib/devtools/index.js",
4+
"module": "../es/devtools/index.js",
5+
"types": "../types/devtools/index.d.ts"
6+
}

docs/src/pages/devtools.md

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,71 @@ When you begin your React Query journey, you'll want these devtools by your side
99

1010
> Please note that for now, the devtools **do not support React Native**. If you would like to help use mae the devtools platform agnostic, please let us know!
1111
12-
## Quick Installation
12+
## Import the Devtools
1313

14-
To get going as fast as possible, do the following:
14+
The devtools are bundle split into the `react-query/devtools` package. No need to install anything extra, just:
1515

16-
```bash
17-
$ npm i react-query-devtools
18-
# or
19-
$ yarn add react-query-devtools
16+
```js
17+
import { ReactQueryDevtools } from 'react-query/devtools'
2018
```
2119

20+
By default, React Query Devtools are not included in production bundles when `process.env.NODE_ENV === 'production'`, so you don't need to worry about excluding them during a production build.
21+
22+
## Floating Mode
23+
24+
Floating Mode will mount the devtools as a fixed, floating element in your app and provide a toggle in the corner of the screen to show and hide the devtools. This toggle state will be stored and remembered in localStorage across reloads.
25+
2226
Place the following code as high in your React app as you can. The closer it is to the root of the page, the better it will work!
2327

2428
```js
25-
import { ReactQueryDevtools } from 'react-query-devtools'
29+
import { ReactQueryDevtools } from 'react-query/devtools'
30+
31+
function App() {
32+
return (
33+
<QueryClientProvider client={queryClient}>
34+
{/* The rest of your application */}
35+
<ReactQueryDevtools initialIsOpen={false} />
36+
</QueryClientProvider>
37+
)
38+
}
39+
```
40+
41+
### Options
42+
43+
- `initialIsOpen: Boolean`
44+
- Set this `true` if you want the dev tools to default to being open
45+
- `panelProps: PropsObject`
46+
- Use this to add props to the panel. For example, you can add `className`, `style` (merge and override default style), etc.
47+
- `closeButtonProps: PropsObject`
48+
- Use this to add props to the close button. For example, you can add `className`, `style` (merge and override default style), `onClick` (extend default handler), etc.
49+
- `toggleButtonProps: PropsObject`
50+
- Use this to add props to the toggle button. For example, you can add `className`, `style` (merge and override default style), `onClick` (extend default handler), etc.
51+
- `position?: "top-left" | "top-right" | "bottom-left" | "bottom-right"`
52+
- Defaults to `bottom-left`
53+
- The position of the React Query logo to open and close the devtools panel
54+
55+
## Embedded Mode
56+
57+
Embedded Mode will embed the devtools as a regular component in your application. You can style it however you'd like after that!
58+
59+
```js
60+
import { ReactQueryDevtoolsPanel } from 'react-query/devtools'
2661

2762
function App() {
2863
return (
29-
<>
64+
<QueryClientProvider client={queryClient}>
3065
{/* The rest of your application */}
31-
<ReactQueryDevtools initialIsOpen />
32-
</>
66+
<ReactQueryDevtoolsPanel style={styles} className={className} />
67+
</QueryClientProvider>
3368
)
3469
}
3570
```
3671

37-
## Need more control?
72+
### Options
73+
74+
Use these options to style the dev tools.
3875

39-
Visit the [React Query Devtools Github Repo](https://github.com/tannerlinsley/react-query-devtools) for more documentation!
76+
- `style: StyleObject`
77+
- The standard React style object used to style a component with inline styles
78+
- `className: string`
79+
- The standard React className property used to style a component with classes

docs/src/pages/guides/migrating-to-react-query-3.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,3 +537,7 @@ The core of React Query is now fully separated from React, which means it can al
537537
```js
538538
import { QueryClient } from 'react-query/core'
539539
```
540+
541+
### Devtools are now part of the main repo and npm package
542+
543+
The devtools are now included in the `react-query` package itself under the import `react-query/devtools`. Simply replace `react-query-devtools` imports with `react-query/devtools`

docs/src/pages/react-native.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ id: react-native
33
title: React Native
44
---
55

6-
React Query is designed to work out of the box with React Native, with an expection to the devtools, which are not supported at this time. If you would like to help us make the devtools platform agnostic, please let us know!
6+
React Query is designed to work out of the box with React Native, with an exeption to the devtools, which are only supported with React DOM at this time. If you would like to help us make the devtools platform agnostic, please let us know!

examples/auto-refetching/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
"next": "9.3.2",
1010
"react": "16.13.0",
1111
"react-dom": "16.13.0",
12-
"react-query": "^3",
13-
"react-query-devtools": "^3"
12+
"react-query": "^3"
1413
},
1514
"scripts": {
1615
"dev": "next",

examples/auto-refetching/pages/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
QueryClient,
1111
QueryClientProvider,
1212
} from 'react-query'
13-
import { ReactQueryDevtools } from 'react-query-devtools'
13+
import { ReactQueryDevtools } from 'react-query/devtools'
1414

1515
const queryClient = new QueryClient()
1616

examples/basic-graphql-request/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"react": "^16.8.6",
1414
"react-dom": "^16.8.6",
1515
"react-query": "^3",
16-
"react-query-devtools": "^3",
1716
"react-scripts": "3.0.1",
1817
"stop-runaway-react-effects": "^1.2.0",
1918
"styled-components": "^4.3.2"

examples/basic-graphql-request/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
QueryClient,
88
QueryClientProvider,
99
} from "react-query";
10-
import { ReactQueryDevtools } from "react-query-devtools";
10+
import { ReactQueryDevtools } from "react-query/devtools";
1111
import { request, gql } from "graphql-request";
1212

1313
const endpoint = "https://graphqlzero.almansi.me/api";

examples/basic/.rescriptsrc.js

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,37 @@
1-
const path = require('path')
2-
const resolveFrom = require('resolve-from')
1+
const path = require("path");
2+
const resolveFrom = require("resolve-from");
33

4-
const fixLinkedDependencies = config => {
4+
const fixLinkedDependencies = (config) => {
55
config.resolve = {
66
...config.resolve,
77
alias: {
88
...config.resolve.alias,
9-
react$: resolveFrom(path.resolve('node_modules'), 'react'),
10-
'react-dom$': resolveFrom(path.resolve('node_modules'), 'react-dom'),
9+
react$: resolveFrom(path.resolve("node_modules"), "react"),
10+
"react-dom$": resolveFrom(path.resolve("node_modules"), "react-dom"),
1111
},
12-
}
13-
return config
14-
}
12+
};
13+
return config;
14+
};
1515

16-
const includeSrcDirectory = config => {
16+
const includeSrcDirectory = (config) => {
1717
config.resolve = {
1818
...config.resolve,
19-
modules: [path.resolve('src'), ...config.resolve.modules],
20-
}
21-
return config
22-
}
19+
modules: [path.resolve("src"), ...config.resolve.modules],
20+
};
21+
return config;
22+
};
23+
24+
const allowOutsideSrc = (config) => {
25+
config.resolve.plugins = config.resolve.plugins.filter(
26+
(p) => p.constructor.name !== "ModuleScopePlugin"
27+
);
28+
return config;
29+
};
2330

2431
module.exports = [
25-
['use-babel-config', '.babelrc'],
26-
['use-eslint-config', '.eslintrc'],
32+
["use-babel-config", ".babelrc"],
33+
["use-eslint-config", ".eslintrc"],
2734
fixLinkedDependencies,
35+
allowOutsideSrc,
2836
// includeSrcDirectory,
29-
]
37+
];

0 commit comments

Comments
 (0)