usePageParams.tsx 656 B

123456789101112131415161718192021222324
  1. import {useMemo} from 'react';
  2. import {decodeList, decodeScalar} from 'sentry/utils/queryString';
  3. export function usePageParams(location) {
  4. const queries = useMemo(() => {
  5. return decodeList(location.query.query);
  6. }, [location.query.query]);
  7. const metricsMax = decodeScalar(location.query.metricsMax);
  8. const metricsMin = decodeScalar(location.query.metricsMin);
  9. const metricsOp = decodeScalar(location.query.metricsOp);
  10. const metricsQuery = decodeScalar(location.query.metricsQuery);
  11. const mri = decodeScalar(location.query.mri);
  12. return {
  13. queries,
  14. metricsMax,
  15. metricsMin,
  16. metricsOp,
  17. metricsQuery,
  18. mri,
  19. };
  20. }