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.
portainer/app/react/hooks/useIdParam.ts

14 lines
335 B

import { useCurrentStateAndParams } from '@uirouter/react';
export function useIdParam(param = 'id'): number {
const { params } = useCurrentStateAndParams();
const stringId = params[param];
const id = parseInt(stringId, 10);
if (!id || Number.isNaN(id)) {
throw new Error('id url param is required');
}
return id;
}