Fix
All checks were successful
Lint / lint (push) Successful in 11s

This commit is contained in:
Julien Valverdé
2025-07-04 18:16:41 +02:00
parent c98e5423cd
commit db822fe85d

View File

@@ -31,13 +31,14 @@ export const useFC: {
self: ReactComponent<E, R, P>, self: ReactComponent<E, R, P>,
options?: ReactHook.ScopeOptions, options?: ReactHook.ScopeOptions,
) { ) {
const runtime = yield* Effect.runtime<Exclude<R, Scope.Scope>>() const runtimeRef = React.useRef<Runtime.Runtime<Exclude<R, Scope.Scope>>>(null!)
runtimeRef.current = yield* Effect.runtime<Exclude<R, Scope.Scope>>()
return React.useMemo(() => function ScopeProvider(props: P) { 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 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) Effect.provideService(self(props), Scope.Scope, scope)
) )
f.displayName = self.displayName ?? "Anonymous" f.displayName = self.displayName ?? "Anonymous"
@@ -46,7 +47,7 @@ export const useFC: {
return React.createElement(FC, props) return React.createElement(FC, props)
}, Array.from( }, Array.from(
Context.omit(...nonReactiveTags)(runtime.context).unsafeMap.values() Context.omit(...nonReactiveTags)(runtimeRef.current.context).unsafeMap.values()
)) ))
}) })