diff --git a/src/lib/components/linetemporalchart/MetricTimespanProvider.tsx b/src/lib/components/linetemporalchart/MetricTimespanProvider.tsx index 8dde187940..25751fff64 100644 --- a/src/lib/components/linetemporalchart/MetricTimespanProvider.tsx +++ b/src/lib/components/linetemporalchart/MetricTimespanProvider.tsx @@ -1,19 +1,18 @@ -import React from 'react'; -import { useEffect, useState, createContext, useContext } from 'react'; -import { useLocation } from 'react-router-dom'; -import { QueryTimeSpan } from '../constants'; -import { queryTimeSpansCodes } from '../constants'; +import { createContext, useContext, useEffect, useState } from 'react'; +import { QueryTimeSpan, queryTimeSpansCodes } from '../constants'; export const MetricsTimeSpanContext = createContext(null); export const MetricsTimeSpanProvider = ({ children, + location, }: { children: JSX.Element; + location?: Location; }) => { // the default timespan is the last 24h const [queryTimeSpanCode, setQueryTimeSpanCode] = useState( queryTimeSpansCodes[1], ); - const urlSearchParams = new URLSearchParams(useLocation().search); + const urlSearchParams = new URLSearchParams(location?.search); const queryTimeSpan = urlSearchParams.get('from'); // Sync url timespan to local timespan useEffect(() => {