@@ -5,7 +5,7 @@ import React from 'react'
55import { useQueryClient } from 'react-query'
66import { matchSorter } from 'match-sorter'
77import useLocalStorage from './useLocalStorage'
8- import { useSafeState } from './utils'
8+ import { useIsMounted , useSafeState } from './utils'
99
1010import {
1111 Panel ,
@@ -95,6 +95,7 @@ export function ReactQueryDevtools({
9595 )
9696 const [ isResolvedOpen , setIsResolvedOpen ] = useSafeState ( false )
9797 const [ isResizing , setIsResizing ] = useSafeState ( false )
98+ const isMounted = useIsMounted ( )
9899
99100 const handleDragStart = ( panelElement , startEvent ) => {
100101 if ( startEvent . button !== 0 ) return // Only allow left click for drag
@@ -196,6 +197,9 @@ export function ReactQueryDevtools({
196197 ...otherToggleButtonProps
197198 } = toggleButtonProps
198199
200+ // Do not render on the server
201+ if ( ! isMounted ( ) ) return null
202+
199203 return (
200204 < Container ref = { rootRef } className = "ReactQueryDevtools" >
201205 < ThemeProvider theme = { theme } >
@@ -428,12 +432,7 @@ export const ReactQueryDevtoolsPanel = React.forwardRef(
428432
429433 return (
430434 < ThemeProvider theme = { theme } >
431- < Panel
432- ref = { ref }
433- className = "ReactQueryDevtoolsPanel"
434- { ...panelProps }
435- suppressHydrationWarning
436- >
435+ < Panel ref = { ref } className = "ReactQueryDevtoolsPanel" { ...panelProps } >
437436 < style
438437 dangerouslySetInnerHTML = { {
439438 __html : `
@@ -505,44 +504,38 @@ export const ReactQueryDevtoolsPanel = React.forwardRef(
505504 >
506505 < QueryKeys style = { { marginBottom : '.5rem' } } >
507506 < QueryKey
508- suppressHydrationWarning
509507 style = { {
510508 background : theme . success ,
511509 opacity : hasFresh ? 1 : 0.3 ,
512510 } }
513511 >
514- fresh < Code suppressHydrationWarning > ({ hasFresh } )</ Code >
512+ fresh < Code > ({ hasFresh } )</ Code >
515513 </ QueryKey > { ' ' }
516514 < QueryKey
517- suppressHydrationWarning
518515 style = { {
519516 background : theme . active ,
520517 opacity : hasFetching ? 1 : 0.3 ,
521518 } }
522519 >
523- fetching{ ' ' }
524- < Code suppressHydrationWarning > ({ hasFetching } )</ Code >
520+ fetching < Code > ({ hasFetching } )</ Code >
525521 </ QueryKey > { ' ' }
526522 < QueryKey
527- suppressHydrationWarning
528523 style = { {
529524 background : theme . warning ,
530525 color : 'black' ,
531526 textShadow : '0' ,
532527 opacity : hasStale ? 1 : 0.3 ,
533528 } }
534529 >
535- stale < Code suppressHydrationWarning > ({ hasStale } )</ Code >
530+ stale < Code > ({ hasStale } )</ Code >
536531 </ QueryKey > { ' ' }
537532 < QueryKey
538- suppressHydrationWarning
539533 style = { {
540534 background : theme . gray ,
541535 opacity : hasInactive ? 1 : 0.3 ,
542536 } }
543537 >
544- inactive{ ' ' }
545- < Code suppressHydrationWarning > ({ hasInactive } )</ Code >
538+ inactive < Code > ({ hasInactive } )</ Code >
546539 </ QueryKey >
547540 </ QueryKeys >
548541 < div
@@ -597,15 +590,13 @@ export const ReactQueryDevtoolsPanel = React.forwardRef(
597590 </ div >
598591 </ div >
599592 < div
600- suppressHydrationWarning
601593 style = { {
602594 overflowY : 'auto' ,
603595 flex : '1' ,
604596 } }
605597 >
606598 { queries . map ( ( query , i ) => (
607599 < div
608- suppressHydrationWarning
609600 key = { query . queryHash || i }
610601 role = "button"
611602 aria-label = { `Open query details for ${ query . queryHash } ` }
@@ -625,7 +616,6 @@ export const ReactQueryDevtoolsPanel = React.forwardRef(
625616 } }
626617 >
627618 < div
628- suppressHydrationWarning
629619 style = { {
630620 flex : '0 0 auto' ,
631621 width : '2rem' ,
@@ -649,7 +639,6 @@ export const ReactQueryDevtoolsPanel = React.forwardRef(
649639 </ div >
650640 { query . isActive ( ) ? null : (
651641 < div
652- suppressHydrationWarning
653642 style = { {
654643 flex : '0 0 auto' ,
655644 height : '2rem' ,
@@ -664,7 +653,6 @@ export const ReactQueryDevtoolsPanel = React.forwardRef(
664653 </ div >
665654 ) }
666655 < Code
667- suppressHydrationWarning
668656 style = { {
669657 padding : '.5rem' ,
670658 } }
0 commit comments