File tree 2 files changed +11
-4
lines changed
2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,12 @@ export const TimeRangeContext = createContext<TimeRangeContextType | null>(
17
17
null
18
18
) ;
19
19
20
- export function useTimeRange ( ) : TimeRangeContextType {
21
- const context = React . useContext ( TimeRangeContext ) ;
20
+ export function useNullableTimeRangeContext ( ) {
21
+ return React . useContext ( TimeRangeContext ) ;
22
+ }
23
+
24
+ export function useTimeRange ( ) {
25
+ const context = useNullableTimeRangeContext ( ) ;
22
26
if ( context === null ) {
23
27
throw new Error (
24
28
"useTimeRange must be used within a TimeRangeContextProvider"
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ import {
24
24
Icons ,
25
25
Loading ,
26
26
Popover ,
27
- useTimeRange ,
27
+ useNullableTimeRangeContext ,
28
28
View ,
29
29
} from "@phoenix/components" ;
30
30
import { Annotation , AnnotationConfig } from "@phoenix/components/annotation" ;
@@ -273,7 +273,10 @@ function SpanAnnotationsList(props: {
273
273
) ;
274
274
const annotationConfigs = data . project ?. annotationConfigs ?. configs ;
275
275
const annotationConfigsLength = annotationConfigs ?. length ?? 0 ;
276
- const { timeRange } = useTimeRange ( ) ;
276
+ // time range is nullable in this context
277
+ // we only use it to refresh fragments after mutations so it is ok to not have a time range context
278
+ const timeRangeContext = useNullableTimeRangeContext ( ) ;
279
+ const timeRange = timeRangeContext ?. timeRange ;
277
280
278
281
const [ commitDeleteAnnotation ] =
279
282
useMutation < SpanAnnotationsEditorDeleteAnnotationMutation > ( graphql `
You can’t perform that action at this time.
0 commit comments