From 36c8a01a5df7a172a3021e125f2554491afc2372 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Valverd=C3=A9?= Date: Tue, 19 Aug 2025 03:01:51 +0200 Subject: [PATCH] Fix --- packages/effect-fc/src/hooks/Hooks/useInput.ts | 1 + packages/effect-fc/src/hooks/Hooks/useOptionalInput.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/effect-fc/src/hooks/Hooks/useInput.ts b/packages/effect-fc/src/hooks/Hooks/useInput.ts index d975edc..19333c9 100644 --- a/packages/effect-fc/src/hooks/Hooks/useInput.ts +++ b/packages/effect-fc/src/hooks/Hooks/useInput.ts @@ -41,6 +41,7 @@ export const useInput: { internalRef.pipe( Effect.andThen(Schema.decode(options.schema)), Effect.andThen(decodedInternalValue => !(options.equivalence ?? Equal.equals)(upstreamValue, decodedInternalValue)), + Effect.catchTag("ParseError", () => Effect.succeed(false)), ), ) ), diff --git a/packages/effect-fc/src/hooks/Hooks/useOptionalInput.ts b/packages/effect-fc/src/hooks/Hooks/useOptionalInput.ts index ea04ee1..d4977d1 100644 --- a/packages/effect-fc/src/hooks/Hooks/useOptionalInput.ts +++ b/packages/effect-fc/src/hooks/Hooks/useOptionalInput.ts @@ -49,7 +49,7 @@ export const useOptionalInput: { yield* useFork(() => Effect.all([ // Sync the upstream state with the internal state - // Only mutate the internal state if the upstream encoded value is actually different. This avoids infinite re-render loops. + // Only mutate the internal state if the upstream value is actually different. This avoids infinite re-render loops. Stream.runForEach(options.ref.changes, Option.match({ onSome: upstreamValue => Effect.whenEffect( Effect.andThen( @@ -59,6 +59,7 @@ export const useOptionalInput: { internalRef.pipe( Effect.andThen(Schema.decode(options.schema)), Effect.andThen(decodedInternalValue => !(options.equivalence ?? Equal.equals)(upstreamValue, decodedInternalValue)), + Effect.catchTag("ParseError", () => Effect.succeed(false)), ), ),