@tanstack/react-query-devtools 4.28.0 → 4.29.0

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": "4.28.0",
3
+ "version": "4.29.0",
4
4
  "description": "Developer tools to interact with and visualize the TanStack/react-query cache",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -661,6 +661,43 @@ describe('ReactQueryDevtools', () => {
661
661
  expect(filterInput.value).toEqual('posts')
662
662
  })
663
663
 
664
+ it('should not show queries after clear', async () => {
665
+ const { queryClient, queryCache } = createQueryClient()
666
+
667
+ function Page() {
668
+ const query1Result = useQuery(['query-1'], async () => {
669
+ return 'query-1-result'
670
+ })
671
+ const query2Result = useQuery(['query-2'], async () => {
672
+ return 'query-2-result'
673
+ })
674
+ const query3Result = useQuery(['query-3'], async () => {
675
+ return 'query-3-result'
676
+ })
677
+
678
+ return (
679
+ <div>
680
+ <h1>
681
+ {query1Result.data} {query2Result.data} {query3Result.data}{' '}
682
+ </h1>
683
+ </div>
684
+ )
685
+ }
686
+
687
+ renderWithClient(queryClient, <Page />)
688
+
689
+ fireEvent.click(
690
+ screen.getByRole('button', { name: /open react query devtools/i }),
691
+ )
692
+
693
+ expect(queryCache.getAll()).toHaveLength(3)
694
+
695
+ const clearButton = screen.getByLabelText(/clear/i)
696
+ fireEvent.click(clearButton)
697
+
698
+ expect(queryCache.getAll()).toHaveLength(0)
699
+ })
700
+
664
701
  it('style should have a nonce', async () => {
665
702
  const { queryClient } = createQueryClient()
666
703
 
package/src/devtools.tsx CHANGED
@@ -597,6 +597,7 @@ export const ReactQueryDevtoolsPanel = React.forwardRef<
597
597
  <Logo aria-hidden />
598
598
  <ScreenReader text="Close React Query Devtools" />
599
599
  </button>
600
+
600
601
  <div
601
602
  style={{
602
603
  display: 'flex',
@@ -673,6 +674,18 @@ export const ReactQueryDevtoolsPanel = React.forwardRef<
673
674
  >
674
675
  {baseSort === 1 ? '⬆ Asc' : '⬇ Desc'}
675
676
  </Button>
677
+ <Button
678
+ title="Clear cache"
679
+ aria-label="Clear cache"
680
+ type="button"
681
+ onClick={() => queryCache.clear()}
682
+ style={{
683
+ padding: '.3em .4em',
684
+ marginRight: '.5em',
685
+ }}
686
+ >
687
+ Clear
688
+ </Button>
676
689
  <Button
677
690
  type="button"
678
691
  onClick={() => {
@@ -1330,5 +1343,7 @@ const QueryRow = React.memo(
1330
1343
  },
1331
1344
  )
1332
1345
 
1346
+ QueryRow.displayName = 'QueryRow'
1347
+
1333
1348
  // eslint-disable-next-line @typescript-eslint/no-empty-function
1334
1349
  function noop() {}