From 795b92cc1a168c48c7710ca6e0e1ef5974013d95 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Thu, 26 Oct 2023 19:07:31 +0200 Subject: refactor(hooks): rewrite useLocalStorage hook * return a tuple instead of an object * add a validator function as parameter (if the stored value is manually changed, it is not safe to cast its type) * add tests --- src/types/app.ts | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/types') diff --git a/src/types/app.ts b/src/types/app.ts index 2e892b8..93ba1db 100644 --- a/src/types/app.ts +++ b/src/types/app.ts @@ -135,3 +135,5 @@ export type Position = 'bottom' | 'center' | 'left' | 'right' | 'top'; /** Spacing keys defined has CSS variables */ export type Spacing = '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl'; + +export type Validator = (value: unknown) => value is T; -- cgit v1.2.3