1
- import { useRef , useState } from 'react' ;
1
+ import { useMemo , useRef , useState } from 'react' ;
2
2
import { Link , useParams } from 'react-router-dom' ;
3
3
import { ReactComponent as ChevronIcon } from '~/assets/chevronDown.svg' ;
4
+ import { useSearch } from '~/integrations/sentry/context/SearchContext' ;
4
5
import classNames from '../../../../../../lib/classNames' ;
5
6
import type { Span , TraceContext } from '../../../../types' ;
6
- import { getSpanDurationClassName , getFormattedDuration } from '../../../../utils/duration' ;
7
+ import { getFormattedDuration , getSpanDurationClassName } from '../../../../utils/duration' ;
7
8
import PlatformIcon from '../../../PlatformIcon' ;
8
9
import SpanResizer from '../../../SpanResizer' ;
9
10
import SpanTree from './SpanTree' ;
@@ -17,7 +18,6 @@ const SpanItem = ({
17
18
totalTransactions = 0 ,
18
19
spanNodeWidth,
19
20
setSpanNodeWidth = ( ) => { } ,
20
- query,
21
21
} : {
22
22
span : Span ;
23
23
startTimestamp : number ;
@@ -27,9 +27,9 @@ const SpanItem = ({
27
27
totalTransactions ?: number ;
28
28
spanNodeWidth : number ;
29
29
setSpanNodeWidth ?: ( val : number ) => void ;
30
- query ?: string ;
31
30
} ) => {
32
31
const { spanId } = useParams ( ) ;
32
+ const { query } = useSearch ( ) ;
33
33
const containerRef = useRef < HTMLLIElement > ( null ) ;
34
34
const childrenCount = span . children ? span . children . length : 0 ;
35
35
const [ isItemCollapsed , setIsItemCollapsed ] = useState (
@@ -47,9 +47,10 @@ const SpanItem = ({
47
47
setSpanNodeWidth ( newLeftWidth ) ;
48
48
}
49
49
} ;
50
- const isQueried = query
51
- ? span . span_id . includes ( query ) || span . op ?. includes ( query ) || span . description ?. includes ( query )
52
- : false ;
50
+ const isQueried = useMemo ( ( ) => {
51
+ if ( ! query ) return false ;
52
+ return span . span_id . includes ( query ) || span . op ?. includes ( query ) || span . description ?. includes ( query ) ;
53
+ } , [ query , span . span_id , span . op , span . description ] ) ;
53
54
54
55
return (
55
56
< li key = { span . span_id } ref = { containerRef } >
@@ -134,7 +135,6 @@ const SpanItem = ({
134
135
totalTransactions = { totalTransactions }
135
136
spanNodeWidth = { spanNodeWidth }
136
137
setSpanNodeWidth = { setSpanNodeWidth }
137
- query = { query }
138
138
/>
139
139
) }
140
140
</ li >
0 commit comments