@@ -1,4 +1,4 @@
|
|||||||
import { Context, Effect, ExecutionStrategy, Function, Pipeable, Runtime, Scope, String, Tracer, type Utils } from "effect"
|
import { Context, Effect, type Equivalence, ExecutionStrategy, Function, Pipeable, Runtime, Scope, String, Tracer, type Utils } from "effect"
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import * as Hook from "./Hook.js"
|
import * as Hook from "./Hook.js"
|
||||||
import type { ExcludeKeys } from "./utils.js"
|
import type { ExcludeKeys } from "./utils.js"
|
||||||
@@ -61,6 +61,27 @@ export const make = <
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export interface Memoized<P extends {}> {
|
||||||
|
readonly memo: true
|
||||||
|
readonly propsAreEqual?: Equivalence.Equivalence<P>
|
||||||
|
}
|
||||||
|
|
||||||
|
export const memo: {
|
||||||
|
<E, R, P extends {}>(
|
||||||
|
context: React.Context<Runtime.Runtime<R>>,
|
||||||
|
): (self: Component<E, R | Scope.Scope, P>) => React.FC<P>
|
||||||
|
<E, R, P extends {}>(
|
||||||
|
self: Component<E, R | Scope.Scope, P>,
|
||||||
|
context: React.Context<Runtime.Runtime<R>>,
|
||||||
|
): React.FC<P>
|
||||||
|
} = Function.dual(2, <E, R, P extends {}>(
|
||||||
|
self: Component<E, R | Scope.Scope, P>,
|
||||||
|
context: React.Context<Runtime.Runtime<R>>,
|
||||||
|
): React.FC<P> => {
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
export const useFC: {
|
export const useFC: {
|
||||||
<E, R, P extends {}>(
|
<E, R, P extends {}>(
|
||||||
self: Component<E, R, P>
|
self: Component<E, R, P>
|
||||||
@@ -99,7 +120,7 @@ export const useSuspenseFC: {
|
|||||||
never,
|
never,
|
||||||
Exclude<R, Scope.Scope>
|
Exclude<R, Scope.Scope>
|
||||||
>
|
>
|
||||||
} = Effect.fn("useSuspenseFC")(function* <E, R, P extends {}>(
|
} = Effect.fn("useSuspenseFC")(function* <E, R, P extends ExcludeKeys<{}, "suspenseProps">>(
|
||||||
self: Component<E, R, P>
|
self: Component<E, R, P>
|
||||||
) {
|
) {
|
||||||
const runtimeRef = React.useRef<Runtime.Runtime<Exclude<R, Scope.Scope>>>(null!)
|
const runtimeRef = React.useRef<Runtime.Runtime<Exclude<R, Scope.Scope>>>(null!)
|
||||||
|
|||||||
Reference in New Issue
Block a user