Fix
Some checks failed
Lint / lint (push) Failing after 9s

This commit is contained in:
Julien Valverdé
2025-01-14 15:29:09 +01:00
parent 4b6cf9a46e
commit cf0951039c
2 changed files with 9 additions and 3 deletions

View File

@@ -19,7 +19,7 @@ export class Reffuse<
) {
this.Provider = parent
? ReffuseReactContext.makeNestedProvider(runtime, this.Context, parent)
: ReffuseReactContext.makeRootProvider<RuntimeR, OwnContextR>(runtime, this.Context)
: ReffuseReactContext.makeRootProvider(runtime, this.Context)
}

View File

@@ -24,15 +24,21 @@ export interface ProviderProps<
readonly children?: React.ReactNode
}
export function makeRootProvider<RuntimeR, ContextR>(
export function makeRootProvider<
RuntimeR,
ContextR extends ParentContextR | OwnContextR,
OwnContextR,
ParentContextR,
>(
runtime: Runtime.Runtime<RuntimeR>,
ReactContext: React.Context<Value<RuntimeR, ContextR>>,
): Provider<RuntimeR, ContextR, never> {
): Provider<RuntimeR, OwnContextR, ParentContextR> {
return function ReffuseRootReactContextProvider(props) {
const value = React.useMemo(() => ({
runtime,
context: Effect.context<ContextR>().pipe(
Effect.provide(props.layer),
Effect.provide(Context.empty() as Context.Context<ParentContextR>), // Just there for type safety. ParentContextR is always never here anyway
Runtime.runSync(runtime),
),
}), [props.layer])