Fix
All checks were successful
Lint / lint (push) Successful in 11s

This commit is contained in:
Julien Valverdé
2025-08-20 16:17:42 +02:00
parent d5b55c5902
commit 9f88486d4d

View File

@@ -51,10 +51,13 @@ export const useOptionalInput: {
// Sync the upstream state with the internal state // Sync the upstream state with the internal state
// Only mutate the internal state if the upstream 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(Stream.changesWith(options.ref.changes, Equivalence.strict()), Option.match({ Stream.runForEach(Stream.changesWith(options.ref.changes, Equivalence.strict()), Option.match({
onSome: upstreamValue => Effect.whenEffect( onSome: upstreamValue => Effect.andThen(
Schema.encode(options.schema)(upstreamValue).pipe( Ref.set(enabledRef, true),
Effect.andThen(encodedUpstreamValue => Ref.set(internalRef, encodedUpstreamValue)),
Effect.andThen(Ref.set(enabledRef, true)), Effect.whenEffect(
Effect.andThen(
Schema.encode(options.schema)(upstreamValue),
encodedUpstreamValue => Ref.set(internalRef, encodedUpstreamValue),
), ),
internalRef.pipe( internalRef.pipe(
Effect.andThen(Schema.decode(options.schema)), Effect.andThen(Schema.decode(options.schema)),
@@ -62,6 +65,7 @@ export const useOptionalInput: {
Effect.catchTag("ParseError", () => Effect.succeed(false)), Effect.catchTag("ParseError", () => Effect.succeed(false)),
), ),
), ),
),
onNone: () => Ref.set(enabledRef, false), onNone: () => Ref.set(enabledRef, false),
})), })),