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) })