mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* Update jest monorepo * Update version of marked so it doesn't throw an error, set testEnvironment * Fix some unit tests * Remove all these tests that aren't actually working... * use spyOn instead of mocking the whole module * Fix linting Co-authored-by: Renovate Bot <bot@renovateapp.com>
12 lines
591 B
TypeScript
12 lines
591 B
TypeScript
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];
|
|
}
|