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.
11 lines
591 B
11 lines
591 B
import { UrlQueryMap } from '@grafana/data';
|
|
import { locationSearchToObject, locationService } from '@grafana/runtime';
|
|
import { useCallback, useMemo } from 'react';
|
|
import { useLocation } from 'react-router-dom';
|
|
|
|
export function useQueryParams(): [UrlQueryMap, (values: UrlQueryMap, replace?: boolean) => void] {
|
|
const { search } = useLocation();
|
|
const queryParams = useMemo(() => locationSearchToObject(search || ''), [search]);
|
|
const update = useCallback((values: UrlQueryMap, replace?: boolean) => locationService.partial(values, replace), []);
|
|
return [queryParams, update];
|
|
}
|
|
|