Skip to content

Commit

Permalink
Refactor MetricTimespanProvider to use useLocation for improved locat…
Browse files Browse the repository at this point in the history
…ion handling
  • Loading branch information
hervedombya committed Dec 11, 2024
1 parent f956f92 commit 95efcf1
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { createContext, useContext, useEffect, useState } from 'react';
import { QueryTimeSpan, queryTimeSpansCodes } from '../constants';
import { useLocation } from 'react-router-dom';
export const MetricsTimeSpanContext = createContext<QueryTimeSpan | null>(null);
export const MetricsTimeSpanProvider = ({
children,
location,
}: {
children: JSX.Element;
location?: Location;
location?: ReturnType<typeof useLocation>;
}) => {
// the default timespan is the last 24h
const [queryTimeSpanCode, setQueryTimeSpanCode] = useState(
Expand Down

0 comments on commit 95efcf1

Please sign in to comment.