useTimeWindowConfig.tsx 499 B

1234567891011121314151617181920
  1. import {useMemo} from 'react';
  2. import {useMonitorDates} from './useMonitorDates';
  3. import {getConfigFromTimeRange} from './utils';
  4. interface Options {
  5. /**
  6. * The width of the timeline influences how we calculate the rollup value
  7. */
  8. timelineWidth: number;
  9. }
  10. export function useTimeWindowConfig({timelineWidth}: Options) {
  11. const {since, until} = useMonitorDates();
  12. return useMemo(
  13. () => getConfigFromTimeRange(since, until, timelineWidth),
  14. [since, until, timelineWidth]
  15. );
  16. }