useLayoutEffect
Some checks failed
Lint / lint (push) Failing after 10s

This commit is contained in:
Julien Valverdé
2025-01-15 23:44:36 +01:00
parent e340ab0c8e
commit ca961e9122

View File

@@ -88,6 +88,26 @@ export class Reffuse<R> {
])
}
useLayoutEffect<A, E>(
effect: Effect.Effect<A, E, R | Scope.Scope>,
deps?: React.DependencyList,
options?: RenderOptions & ScopeOptions,
): void {
const runSync = this.useRunSync()
return React.useLayoutEffect(() => {
const scope = Scope.make(options?.finalizerExecutionStrategy).pipe(
Effect.tap(scope => Effect.provideService(effect, Scope.Scope, scope)),
runSync,
)
return () => runSync(Scope.close(scope, Exit.void))
}, [
...options?.doNotReExecuteOnRuntimeOrContextChange ? [] : [runSync],
...(deps ?? []),
])
}
useSuspense<A, E>(
effect: Effect.Effect<A, E, R>,
options?: { readonly signal?: AbortSignal },