Component displayName
All checks were successful
Lint / lint (push) Successful in 14s

This commit is contained in:
Julien Valverdé
2025-06-30 00:37:16 +02:00
parent 2ef47bed70
commit 37d9400ada

View File

@@ -5,6 +5,7 @@ import * as ReactHook from "./ReactHook.js"
export interface ReactComponent<P, E, R> { export interface ReactComponent<P, E, R> {
(props: P): Effect.Effect<React.ReactNode, E, R> (props: P): Effect.Effect<React.ReactNode, E, R>
readonly displayName?: string
} }
export const nonReactiveTags = [Tracer.ParentSpan] as const export const nonReactiveTags = [Tracer.ParentSpan] as const
@@ -21,7 +22,9 @@ export const useFC: {
const runtime = yield* Effect.runtime<R>() const runtime = yield* Effect.runtime<R>()
return React.useMemo(() => { return React.useMemo(() => {
return (props: P) => Runtime.runSync(runtime)(self(props)) const FC = (props: P) => Runtime.runSync(runtime)(self(props))
if (self.displayName) FC.displayName = self.displayName
return FC
}, Array.from( }, Array.from(
Context.omit(...nonReactiveTags)(runtime.context).unsafeMap.values() Context.omit(...nonReactiveTags)(runtime.context).unsafeMap.values()
)) ))