The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/core/navigation/hooks.ts

18 lines
628 B

import { useLocation } from 'react-router-dom-v5-compat';
import { locationService } from '@grafana/runtime';
export type UseUrlParamsResult = [URLSearchParams, (params: Record<string, unknown>, replace?: boolean) => void];
/** @internal experimental */
export function useUrlParams(): UseUrlParamsResult {
const location = useLocation();
const params = new URLSearchParams(location.search);
const updateUrlParams = (params: Record<string, unknown>, replace?: boolean) => {
// Should find a way to use history directly here
locationService.partial(params, replace);
};
return [params, updateUrlParams];
}