Refactor Component
Lint / lint (push) Failing after 16s

This commit is contained in:
Julien Valverdé
2026-06-23 03:57:56 +02:00
parent 24ce543092
commit a86cb7e024
2 changed files with 19 additions and 394 deletions
+19 -9
View File
@@ -83,16 +83,26 @@ const use = Effect.fnUntraced(function* <P extends {}, A extends React.ReactNode
const contextRef = React.useRef<Context.Context<Exclude<R, Scope.Scope>>>(null!)
contextRef.current = yield* Effect.context<Exclude<R, Scope.Scope>>()
return yield* React.useState(() => Effect.runSyncWith(contextRef.current)(Effect.cachedFunction(
(_services: readonly any[]) => Effect.sync(() => {
const f = self.asFunctionComponent(contextRef)
self.setFunctionComponentName(f)
return self.transformFunctionComponent(f)
}),
Equivalence.array(Equivalence.strictEqual()),
)))[0](Array.from(
const componentRef = React.useRef<F | null>(null)
const previousServicesRef = React.useRef<readonly any[] | null>(null)
const services = Array.from(
Context.omit(...self.nonReactiveTags)(contextRef.current).mapUnsafe.values()
))
)
if (
!componentRef.current ||
!previousServicesRef.current ||
services.length !== previousServicesRef.current.length ||
!Equivalence.Array(Equivalence.strictEqual())(services, previousServicesRef.current)
) {
previousServicesRef.current = services
const f = self.asFunctionComponent(contextRef)
self.setFunctionComponentName(f)
componentRef.current = self.transformFunctionComponent(f)
}
return componentRef.current
})