mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 16:15:42 -06:00
* more friday any/type assertion improvements * Apply suggestions from code review Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com> * Update public/app/angular/promiseToDigest.test.ts Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com> Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com>
19 lines
618 B
TypeScript
19 lines
618 B
TypeScript
import { useLocation } from 'react-router-dom';
|
|
|
|
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];
|
|
}
|