@@ -14,6 +14,7 @@ import {
14
14
Input ,
15
15
Select ,
16
16
QueryCountStyles ,
17
+ ActiveQueryPanel ,
17
18
} from './styledComponents'
18
19
import { ThemeProvider } from './theme'
19
20
import {
@@ -207,7 +208,7 @@ export function ReactQueryDevtools({
207
208
}
208
209
209
210
const getStatusRank = q =>
210
- q . state . isFetching ? 0 : ! q . instances . length ? 3 : q . state . isStale ? 2 : 1
211
+ q . state . isFetching ? 0 : ! q . observers . length ? 3 : q . state . isStale ? 2 : 1
211
212
212
213
const sortFns = {
213
214
'Status > Last Updated' : ( a , b ) =>
@@ -282,7 +283,10 @@ export const ReactQueryDevtoolsPanel = React.forwardRef(
282
283
Object . values ( queryCache . queries )
283
284
)
284
285
285
- const [ activeQueryHash , setActiveQueryHash ] = React . useState ( null )
286
+ const [ activeQueryHash , setActiveQueryHash ] = useLocalStorage (
287
+ 'reactQueryDevtoolsActiveQueryHash' ,
288
+ ''
289
+ )
286
290
287
291
const queries = React . useMemo ( ( ) => {
288
292
const sorted = [ ...unsortedQueries ] . sort ( sortFn )
@@ -296,17 +300,8 @@ export const ReactQueryDevtoolsPanel = React.forwardRef(
296
300
)
297
301
} , [ sortDesc , sortFn , unsortedQueries , filter ] )
298
302
299
- const [ activeQuery , activeQueryJson ] = React . useMemo ( ( ) => {
300
- const activeQuery = queries . find (
301
- query => query . queryHash === activeQueryHash
302
- )
303
-
304
- return [
305
- activeQuery ,
306
- activeQuery
307
- ? JSON . parse ( JSON . stringify ( activeQuery , getCircularReplacer ( ) ) )
308
- : null ,
309
- ]
303
+ const activeQuery = React . useMemo ( ( ) => {
304
+ return queries . find ( query => query . queryHash === activeQueryHash )
310
305
} , [ activeQueryHash , queries ] )
311
306
312
307
const hasFresh = queries . filter ( q => getQueryStatusLabel ( q ) === 'fresh' )
@@ -326,12 +321,6 @@ export const ReactQueryDevtoolsPanel = React.forwardRef(
326
321
} )
327
322
} , [ sort , sortFn , sortDesc , queryCache ] )
328
323
329
- React . useEffect ( ( ) => {
330
- if ( activeQueryHash && ! activeQuery ) {
331
- setActiveQueryHash ( null )
332
- }
333
- } , [ activeQuery , activeQueryHash ] )
334
-
335
324
return (
336
325
< ThemeProvider theme = { theme } >
337
326
< Panel ref = { ref } className = "ReactQueryDevtoolsPanel" { ...panelProps } >
@@ -508,7 +497,7 @@ export const ReactQueryDevtoolsPanel = React.forwardRef(
508
497
: 'white' ,
509
498
} }
510
499
>
511
- { query . instances . length }
500
+ { query . observers . length }
512
501
</ div >
513
502
< Code
514
503
style = { {
@@ -522,55 +511,72 @@ export const ReactQueryDevtoolsPanel = React.forwardRef(
522
511
</ div >
523
512
</ div >
524
513
{ activeQuery ? (
525
- < div
526
- style = { {
527
- flex : '1 1 500px' ,
528
- display : 'flex' ,
529
- flexDirection : 'column' ,
530
- overflow : 'auto' ,
531
- height : '100%' ,
532
- } }
533
- >
514
+ < ActiveQueryPanel >
534
515
< div
535
516
style = { {
536
517
padding : '.5rem' ,
537
518
background : theme . backgroundAlt ,
519
+ position : 'sticky' ,
520
+ top : 0 ,
521
+ zIndex : 1 ,
538
522
} }
539
523
>
540
524
Query Details
541
525
</ div >
542
526
< div
543
527
style = { {
544
- padding : '1rem' ,
545
- display : 'flex' ,
546
- alignItems : 'center' ,
547
- justifyContent : 'space-between' ,
528
+ padding : '.5rem 0' ,
548
529
} }
549
530
>
550
- < Code
531
+ < div
551
532
style = { {
552
- lineHeight : '1.8rem' ,
533
+ padding : '.5rem 1rem' ,
534
+ display : 'flex' ,
535
+ alignItems : 'center' ,
536
+ justifyContent : 'space-between' ,
553
537
} }
554
538
>
555
- { activeQuery . queryHash }
556
- </ Code >
557
- < span
539
+ < Code
540
+ style = { {
541
+ lineHeight : '1.8rem' ,
542
+ } }
543
+ >
544
+ { activeQuery . queryHash }
545
+ </ Code >
546
+ < span
547
+ style = { {
548
+ padding : '0.3rem .6rem' ,
549
+ borderRadius : '0.4rem' ,
550
+ fontWeight : 'bold' ,
551
+ textShadow : '0 2px 10px black' ,
552
+ background : getQueryStatusColor ( activeQuery , theme ) ,
553
+ flexShrink : 0 ,
554
+ } }
555
+ >
556
+ { getQueryStatusLabel ( activeQuery ) }
557
+ </ span >
558
+ </ div >
559
+ < div
558
560
style = { {
559
- padding : '0.3rem .6rem' ,
560
- borderRadius : '0.4rem' ,
561
- fontWeight : 'bold' ,
562
- textShadow : '0 2px 10px black' ,
563
- background : getQueryStatusColor ( activeQuery , theme ) ,
564
- flexShrink : 0 ,
561
+ padding : '.5rem 1rem' ,
562
+ display : 'flex' ,
563
+ alignItems : 'center' ,
564
+ justifyContent : 'space-between' ,
565
565
} }
566
566
>
567
- { getQueryStatusLabel ( activeQuery ) }
568
- </ span >
567
+ Last Updated:{ ' ' }
568
+ < Code >
569
+ { new Date ( activeQuery . state . updatedAt ) . toLocaleTimeString ( ) }
570
+ </ Code >
571
+ </ div >
569
572
</ div >
570
573
< div
571
574
style = { {
572
575
background : theme . backgroundAlt ,
573
576
padding : '.5rem' ,
577
+ position : 'sticky' ,
578
+ top : 0 ,
579
+ zIndex : 1 ,
574
580
} }
575
581
>
576
582
Actions
@@ -604,6 +610,9 @@ export const ReactQueryDevtoolsPanel = React.forwardRef(
604
610
style = { {
605
611
background : theme . backgroundAlt ,
606
612
padding : '.5rem' ,
613
+ position : 'sticky' ,
614
+ top : 0 ,
615
+ zIndex : 1 ,
607
616
} }
608
617
>
609
618
Data Explorer
@@ -615,14 +624,17 @@ export const ReactQueryDevtoolsPanel = React.forwardRef(
615
624
>
616
625
< Explorer
617
626
label = "Data"
618
- value = { activeQueryJson . state . data }
627
+ value = { activeQuery ? .state ? .data }
619
628
defaultExpanded = { { } }
620
629
/>
621
630
</ div >
622
631
< div
623
632
style = { {
624
633
background : theme . backgroundAlt ,
625
634
padding : '.5rem' ,
635
+ position : 'sticky' ,
636
+ top : 0 ,
637
+ zIndex : 1 ,
626
638
} }
627
639
>
628
640
Query Explorer
@@ -634,13 +646,13 @@ export const ReactQueryDevtoolsPanel = React.forwardRef(
634
646
>
635
647
< Explorer
636
648
label = "Query"
637
- value = { activeQueryJson }
649
+ value = { activeQuery }
638
650
defaultExpanded = { {
639
651
queryKey : true ,
640
652
} }
641
653
/>
642
654
</ div >
643
- </ div >
655
+ </ ActiveQueryPanel >
644
656
) : null }
645
657
</ Panel >
646
658
</ ThemeProvider >
0 commit comments