From eff379a63eeaa808960aa7e6d745a252af489ba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Valverd=C3=A9?= Date: Wed, 9 Jul 2025 03:31:19 +0200 Subject: [PATCH] Component refactoring --- packages/effect-fc/src/Component.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/effect-fc/src/Component.ts b/packages/effect-fc/src/Component.ts index fbb33c4..2b0c5f6 100644 --- a/packages/effect-fc/src/Component.ts +++ b/packages/effect-fc/src/Component.ts @@ -68,8 +68,13 @@ export const useFC: { const runtimeRef = React.useRef>>(null!) runtimeRef.current = yield* Effect.runtime>() - return React.useMemo(() => function ScopeProvider(props: P) { - const scope = Runtime.runSync(runtimeRef.current)(Hook.useScope([], self.options)) + return React.useCallback(function ScopeProvider(props: P) { + const scope = Runtime.runSync(runtimeRef.current)(Hook.useScope( + Array.from( + Context.omit(...nonReactiveTags)(runtimeRef.current.context).unsafeMap.values() + ), + self.options, + )) const FC = React.useMemo(() => { const f = (props: P) => Runtime.runSync(runtimeRef.current)( @@ -80,9 +85,7 @@ export const useFC: { }, [scope]) return React.createElement(FC, props) - }, Array.from( - Context.omit(...nonReactiveTags)(runtimeRef.current.context).unsafeMap.values() - )) + }, []) }) export const useSuspenseFC: {