diff --git a/frontend/src/hooks/useValidatedState.ts b/frontend/src/hooks/useValidatedState.ts index b774ef3..15785ce 100644 --- a/frontend/src/hooks/useValidatedState.ts +++ b/frontend/src/hooks/useValidatedState.ts @@ -23,7 +23,6 @@ export type ValidatedState = [T, React.Dispatch>, Val /** * Hook that extends {@link React.useState} by applying a {@link Validator} to the stored value, returning its results to the caller. * - * @todo Improve this docstring. * @param def - Default value for the state. * @param validator - The {@link Validator} to apply. */ @@ -34,7 +33,12 @@ export function useValidatedState(def: T, validator: Validator): Validated const validity = React.useMemo( () => { - return validator(value) + try { + return validator(value) + } + catch (e) { + return "error" + } }, [validator, value] )