44 * you may not use this file except in compliance with the Elastic License.
55 */
66
7- import React from 'react' ;
7+ import React , { useCallback } from 'react' ;
88import { Route , Switch } from 'react-router-dom' ;
99import { EuiFlexItem , EuiSpacer } from '@elastic/eui' ;
1010
@@ -19,7 +19,7 @@ import { DnsQueryTabBody } from './dns_query_tab_body';
1919import { ConditionalFlexGroup } from './conditional_flex_group' ;
2020import { NetworkRoutesProps , NetworkRouteType } from './types' ;
2121import { TlsQueryTabBody } from './tls_query_tab_body' ;
22- import { Anomaly , NarrowDateRange } from '../../../components/ml/types' ;
22+ import { Anomaly } from '../../../components/ml/types' ;
2323
2424export const NetworkRoutes = ( {
2525 networkPagePath,
@@ -32,17 +32,23 @@ export const NetworkRoutes = ({
3232 setQuery,
3333 setAbsoluteRangeDatePicker,
3434} : NetworkRoutesProps ) => {
35- const narrowDateRange : NarrowDateRange = ( score : Anomaly , interval : string ) => {
36- const fromTo = scoreIntervalToDateTime ( score , interval ) ;
37- setAbsoluteRangeDatePicker ( {
38- id : 'global' ,
39- from : fromTo . from ,
40- to : fromTo . to ,
41- } ) ;
42- } ;
43- const updateDateRange = ( min : number , max : number ) => {
44- setAbsoluteRangeDatePicker ( { id : 'global' , from : min , to : max } ) ;
45- } ;
35+ const narrowDateRange = useCallback (
36+ ( score : Anomaly , interval : string ) => {
37+ const fromTo = scoreIntervalToDateTime ( score , interval ) ;
38+ setAbsoluteRangeDatePicker ( {
39+ id : 'global' ,
40+ from : fromTo . from ,
41+ to : fromTo . to ,
42+ } ) ;
43+ } ,
44+ [ scoreIntervalToDateTime , setAbsoluteRangeDatePicker ]
45+ ) ;
46+ const updateDateRange = useCallback (
47+ ( min : number , max : number ) => {
48+ setAbsoluteRangeDatePicker ( { id : 'global' , from : min , to : max } ) ;
49+ } ,
50+ [ from , to ]
51+ ) ;
4652
4753 const tabProps = {
4854 networkPagePath,
0 commit comments