@tanstack/react-query-devtools 5.0.0-alpha.14 → 5.0.0-alpha.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-query-devtools",
3
- "version": "5.0.0-alpha.14",
3
+ "version": "5.0.0-alpha.18",
4
4
  "description": "Developer tools to interact with and visualize the TanStack/react-query cache",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -43,7 +43,7 @@
43
43
  "react": "^18.2.0",
44
44
  "react-dom": "^18.2.0",
45
45
  "react-error-boundary": "^3.1.4",
46
- "@tanstack/react-query": "5.0.0-alpha.12"
46
+ "@tanstack/react-query": "5.0.0-alpha.18"
47
47
  },
48
48
  "dependencies": {
49
49
  "@tanstack/match-sorter-utils": "^8.7.0",
@@ -52,7 +52,7 @@
52
52
  "peerDependencies": {
53
53
  "react": "^18.0.0",
54
54
  "react-dom": "^18.0.0",
55
- "@tanstack/react-query": "5.0.0-alpha.12"
55
+ "@tanstack/react-query": "5.0.0-alpha.18"
56
56
  },
57
57
  "scripts": {
58
58
  "clean": "rimraf ./build",
@@ -298,6 +298,18 @@ export const ReactQueryDevtoolsPanel = React.forwardRef<
298
298
  >
299
299
  {baseSort === 1 ? '⬆ Asc' : '⬇ Desc'}
300
300
  </Button>
301
+ <Button
302
+ title="Clear cache"
303
+ aria-label="Clear cache"
304
+ type="button"
305
+ onClick={() => queryCache.clear()}
306
+ style={{
307
+ padding: '.3em .4em',
308
+ marginRight: '.5em',
309
+ }}
310
+ >
311
+ Clear
312
+ </Button>
301
313
  <Button
302
314
  type="button"
303
315
  onClick={() => {
@@ -717,6 +717,52 @@ describe('ReactQueryDevtools', () => {
717
717
  expect(filterInput.value).toEqual('posts')
718
718
  })
719
719
 
720
+ it('should not show queries after clear', async () => {
721
+ const { queryClient, queryCache } = createQueryClient()
722
+
723
+ function Page() {
724
+ const query1Result = useQuery({
725
+ queryKey: ['query-1'],
726
+ queryFn: async () => {
727
+ return 'query-1-result'
728
+ },
729
+ })
730
+ const query2Result = useQuery({
731
+ queryKey: ['query-2'],
732
+ queryFn: async () => {
733
+ return 'query-2-result'
734
+ },
735
+ })
736
+ const query3Result = useQuery({
737
+ queryKey: ['query-3'],
738
+ queryFn: async () => {
739
+ return 'query-3-result'
740
+ },
741
+ })
742
+
743
+ return (
744
+ <div>
745
+ <h1>
746
+ {query1Result.data} {query2Result.data} {query3Result.data}{' '}
747
+ </h1>
748
+ </div>
749
+ )
750
+ }
751
+
752
+ renderWithClient(queryClient, <Page />)
753
+
754
+ fireEvent.click(
755
+ screen.getByRole('button', { name: /open react query devtools/i }),
756
+ )
757
+
758
+ expect(queryCache.getAll()).toHaveLength(3)
759
+
760
+ const clearButton = screen.getByLabelText(/clear/i)
761
+ fireEvent.click(clearButton)
762
+
763
+ expect(queryCache.getAll()).toHaveLength(0)
764
+ })
765
+
720
766
  it('style should have a nonce', async () => {
721
767
  const { queryClient } = createQueryClient()
722
768