From db822fe85dd664345ce76a97e5e68cdfc2f330e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Valverd=C3=A9?= Date: Fri, 4 Jul 2025 18:16:41 +0200 Subject: [PATCH] Fix --- packages/effect-fc/src/ReactComponent.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/effect-fc/src/ReactComponent.ts b/packages/effect-fc/src/ReactComponent.ts index 618703a..aacec01 100644 --- a/packages/effect-fc/src/ReactComponent.ts +++ b/packages/effect-fc/src/ReactComponent.ts @@ -31,13 +31,14 @@ export const useFC: { self: ReactComponent, options?: ReactHook.ScopeOptions, ) { - const runtime = yield* Effect.runtime>() + const runtimeRef = React.useRef>>(null!) + runtimeRef.current = yield* Effect.runtime>() return React.useMemo(() => function ScopeProvider(props: P) { - const scope = Runtime.runSync(runtime)(ReactHook.useScope(options)) + const scope = Runtime.runSync(runtimeRef.current)(ReactHook.useScope(options)) const FC = React.useMemo(() => { - const f = (props: P) => Runtime.runSync(runtime)( + const f = (props: P) => Runtime.runSync(runtimeRef.current)( Effect.provideService(self(props), Scope.Scope, scope) ) f.displayName = self.displayName ?? "Anonymous" @@ -46,7 +47,7 @@ export const useFC: { return React.createElement(FC, props) }, Array.from( - Context.omit(...nonReactiveTags)(runtime.context).unsafeMap.values() + Context.omit(...nonReactiveTags)(runtimeRef.current.context).unsafeMap.values() )) })