mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-28 00:06:53 +01:00
33b5e4abac
* refactor: ensure that [hidden] overrides other display styles * refactor: use numeric font weights * refactor: remove unnecessary Jest mock * refactor: add a fullWidth prop to GeneralSelect * refactor: remove unnecessary label id prop * refactor: the showActive prop is optional * refactor: add hooks for managing query string state * refactor: add a hour/minute timestamp formatter * refactor: add labels to button icons * feat: add new feature metrics page * refactor: remove prev feature metrics page * refactor: use new metric boxes on overview page * refactor: lazy-load the new metrics page * refactor: fix type error when formatting unknown error * refactor: extract interfaces for props * refactor: destructure all props * refactor: expand arg names * refactor: reorg component dirs and files * refactor: improve chart element label * refactor: hide chart dots until hover * refactor: add section titles to environments/applications * refactor: simplify FeatureMetricsHours types * refactor: sort chart tooltip items * refactor: add more chart labels * refactor: always show a dot in single point charts * refactor: improve chart tooltip styles * refactor: adjut metric page spacing * refactor: decrease legend box size * refactor: move date fmt fn inline * refactor: improve chart legend styles * refactor: increase Cypress timeouts * refactor: sort environment and application chips * refactor: format files * refactor: use stable lists of apps and envs * refactor: fix FeatureMetrics dir name * refactor: avoid ScrollToTop on query string change * refactor: use ConditionallyRender instead of inline condition * refactor: use makeStyles instead of styled API
20 lines
572 B
TypeScript
20 lines
572 B
TypeScript
import { useCallback } from 'react';
|
|
import { useQueryStringState } from './useQueryStringState';
|
|
|
|
// Store a number in the query string. Call setState to update the query string.
|
|
export const useQueryStringNumberState = (
|
|
key: string
|
|
): [number | undefined, (value: number) => void] => {
|
|
const [value, setValue] = useQueryStringState(key);
|
|
|
|
const setState = useCallback(
|
|
(value: number) => setValue(String(value)),
|
|
[setValue]
|
|
);
|
|
|
|
return [
|
|
Number.isFinite(Number(value)) ? Number(value) : undefined,
|
|
setState,
|
|
];
|
|
};
|