From 6b39671d60ea134671933c523795e50d3b174cf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Valverd=C3=A9?= Date: Mon, 28 Jul 2025 04:20:04 +0200 Subject: [PATCH] Fix --- packages/effect-fc/src/Component.ts | 2 +- packages/effect-fc/src/hooks/useCallbackPromise.ts | 6 ++++-- packages/effect-fc/src/hooks/useCallbackSync.ts | 6 ++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/effect-fc/src/Component.ts b/packages/effect-fc/src/Component.ts index 6cf7585..36205bf 100644 --- a/packages/effect-fc/src/Component.ts +++ b/packages/effect-fc/src/Component.ts @@ -34,7 +34,7 @@ const ComponentProto = Object.freeze({ ...Effectable.CommitPrototype, [TypeId]: TypeId, - commit: Effect.fn("Component")(function*

(this: Component) { + commit: Effect.fnUntraced(function*

(this: Component) { const self = this const runtimeRef = React.useRef>>(null!) runtimeRef.current = yield* Effect.runtime>() diff --git a/packages/effect-fc/src/hooks/useCallbackPromise.ts b/packages/effect-fc/src/hooks/useCallbackPromise.ts index 5e093ef..be075ea 100644 --- a/packages/effect-fc/src/hooks/useCallbackPromise.ts +++ b/packages/effect-fc/src/hooks/useCallbackPromise.ts @@ -11,6 +11,8 @@ export const useCallbackPromise: { callback: (...args: Args) => Effect.Effect, deps: React.DependencyList, ) { - const runtime = yield* Effect.runtime() - return React.useCallback((...args: Args) => Runtime.runPromise(runtime)(callback(...args)), deps) + const runtimeRef = React.useRef>(null!) + runtimeRef.current = yield* Effect.runtime() + + return React.useCallback((...args: Args) => Runtime.runPromise(runtimeRef.current)(callback(...args)), deps) }) diff --git a/packages/effect-fc/src/hooks/useCallbackSync.ts b/packages/effect-fc/src/hooks/useCallbackSync.ts index 07ffd84..44a41cc 100644 --- a/packages/effect-fc/src/hooks/useCallbackSync.ts +++ b/packages/effect-fc/src/hooks/useCallbackSync.ts @@ -11,6 +11,8 @@ export const useCallbackSync: { callback: (...args: Args) => Effect.Effect, deps: React.DependencyList, ) { - const runtime = yield* Effect.runtime() - return React.useCallback((...args: Args) => Runtime.runSync(runtime)(callback(...args)), deps) + const runtimeRef = React.useRef>(null!) + runtimeRef.current = yield* Effect.runtime() + + return React.useCallback((...args: Args) => Runtime.runSync(runtimeRef.current)(callback(...args)), deps) })