diff --git a/packages/effect-fc/src/hooks/Hooks/input/useOptionalInput.ts b/packages/effect-fc/src/hooks/Hooks/input/useOptionalInput.ts index 3a77d6c..08eae54 100644 --- a/packages/effect-fc/src/hooks/Hooks/input/useOptionalInput.ts +++ b/packages/effect-fc/src/hooks/Hooks/input/useOptionalInput.ts @@ -52,9 +52,9 @@ export const useOptionalInput: { // 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({ onSome: upstreamValue => Effect.whenEffect( - Effect.andThen( - Schema.encode(options.schema)(upstreamValue), - encodedUpstreamValue => Ref.set(internalRef, encodedUpstreamValue), + Schema.encode(options.schema)(upstreamValue).pipe( + Effect.andThen(encodedUpstreamValue => Ref.set(internalRef, encodedUpstreamValue)), + Effect.andThen(Ref.set(enabledRef, true)), ), internalRef.pipe( Effect.andThen(Schema.decode(options.schema)), diff --git a/packages/effect-fc/src/hooks/Hooks/useRefState.ts b/packages/effect-fc/src/hooks/Hooks/useRefState.ts index 95d948d..6cc3980 100644 --- a/packages/effect-fc/src/hooks/Hooks/useRefState.ts +++ b/packages/effect-fc/src/hooks/Hooks/useRefState.ts @@ -14,7 +14,7 @@ export const useRefState: { const [reactStateValue, setReactStateValue] = React.useState(yield* useOnce(() => ref)) yield* useFork(() => Stream.runForEach( - Stream.drop(Stream.changesWith(ref.changes, Equivalence.strict()), 1), + Stream.changesWith(ref.changes, Equivalence.strict()), v => Effect.sync(() => setReactStateValue(v)), ), [ref]) diff --git a/packages/effect-fc/src/hooks/Hooks/useSubscribeRefs.ts b/packages/effect-fc/src/hooks/Hooks/useSubscribeRefs.ts index 7e62bd2..b6346c4 100644 --- a/packages/effect-fc/src/hooks/Hooks/useSubscribeRefs.ts +++ b/packages/effect-fc/src/hooks/Hooks/useSubscribeRefs.ts @@ -16,7 +16,7 @@ export const useSubscribeRefs: { )) yield* useFork(() => pipe( - refs.map(ref => Stream.drop(Stream.changesWith(ref.changes, Equivalence.strict()), 1)), + refs.map(ref => Stream.changesWith(ref.changes, Equivalence.strict())), streams => Stream.zipLatestAll(...streams), Stream.runForEach(v => Effect.sync(() => setReactStateValue(v))