This commit is contained in:
@@ -341,14 +341,11 @@ export const withOptions: {
|
|||||||
|
|
||||||
|
|
||||||
export const useFC: {
|
export const useFC: {
|
||||||
<E, R, P extends {}>(
|
|
||||||
self: Component<E, R, P> & Suspense.Suspense
|
|
||||||
): Effect.Effect<React.FC<P & Suspense.Suspense.Props>, never, Exclude<R, Scope.Scope>>
|
|
||||||
<E, R, P extends {}>(
|
<E, R, P extends {}>(
|
||||||
self: Component<E, R, P>
|
self: Component<E, R, P>
|
||||||
): Effect.Effect<React.FC<P>, never, Exclude<R, Scope.Scope>>
|
): Effect.Effect<React.FC<P>, never, Exclude<R, Scope.Scope>>
|
||||||
} = Effect.fn("useFC")(function* <E, R, P extends {}>(
|
} = Effect.fn("useFC")(function* <E, R, P extends {}>(
|
||||||
self: Component<E, R, P> & (Memoized.Memoized<P> | Suspense.Suspense | {})
|
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!)
|
||||||
runtimeRef.current = yield* Effect.runtime<Exclude<R, Scope.Scope>>()
|
runtimeRef.current = yield* Effect.runtime<Exclude<R, Scope.Scope>>()
|
||||||
@@ -395,10 +392,6 @@ export const useFC: {
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const use: {
|
export const use: {
|
||||||
<E, R, P extends {}>(
|
|
||||||
self: Component<E, R, P> & Suspense.Suspense,
|
|
||||||
fn: (Component: React.FC<P & Suspense.Suspense.Props>) => React.ReactNode,
|
|
||||||
): Effect.Effect<React.ReactNode, never, Exclude<R, Scope.Scope>>
|
|
||||||
<E, R, P extends {}>(
|
<E, R, P extends {}>(
|
||||||
self: Component<E, R, P>,
|
self: Component<E, R, P>,
|
||||||
fn: (Component: React.FC<P>) => React.ReactNode,
|
fn: (Component: React.FC<P>) => React.ReactNode,
|
||||||
@@ -408,16 +401,9 @@ export const use: {
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const withRuntime: {
|
export const withRuntime: {
|
||||||
<T extends Component<any, R, any>, R>(
|
|
||||||
context: React.Context<Runtime.Runtime<R>>,
|
|
||||||
): (self: T) => React.FC<T extends Suspense.Suspense
|
|
||||||
? Component.Props<T> & Suspense.Suspense.Props
|
|
||||||
: Component.Props<T>
|
|
||||||
>
|
|
||||||
<E, R, P extends {}>(
|
<E, R, P extends {}>(
|
||||||
self: Component<E, R, P> & Suspense.Suspense,
|
|
||||||
context: React.Context<Runtime.Runtime<R>>,
|
context: React.Context<Runtime.Runtime<R>>,
|
||||||
): React.FC<P & Suspense.Suspense.Props>
|
): (self: Component<E, R, P>) => React.FC<P>
|
||||||
<E, R, P extends {}>(
|
<E, R, P extends {}>(
|
||||||
self: Component<E, R, P>,
|
self: Component<E, R, P>,
|
||||||
context: React.Context<Runtime.Runtime<R>>,
|
context: React.Context<Runtime.Runtime<R>>,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Flex, Text, TextField } from "@radix-ui/themes"
|
|||||||
import { createFileRoute } from "@tanstack/react-router"
|
import { createFileRoute } from "@tanstack/react-router"
|
||||||
import { GetRandomValues, makeUuid4 } from "@typed/id"
|
import { GetRandomValues, makeUuid4 } from "@typed/id"
|
||||||
import { Effect } from "effect"
|
import { Effect } from "effect"
|
||||||
import { Component } from "effect-fc"
|
import { Component, Memoized, Suspense } from "effect-fc"
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
|
|
||||||
|
|
||||||
@@ -34,11 +34,11 @@ class SubComponent extends Component.make(function* SubComponent(props: { readon
|
|||||||
}) {}
|
}) {}
|
||||||
|
|
||||||
class MemoizedSubComponent extends SubComponent.pipe(
|
class MemoizedSubComponent extends SubComponent.pipe(
|
||||||
Component.memo,
|
Memoized.memo,
|
||||||
Component.suspense,
|
Suspense.suspense,
|
||||||
Component.memo,
|
Memoized.memo,
|
||||||
) {}
|
) {}
|
||||||
type T = typeof MemoizedSubComponent extends Component.Memoized<infer P> ? P : never
|
type T = typeof MemoizedSubComponent extends Memoized.Memoized<infer P> ? P : never
|
||||||
|
|
||||||
export const Route = createFileRoute("/dev/memo")({
|
export const Route = createFileRoute("/dev/memo")({
|
||||||
component: RouteComponent,
|
component: RouteComponent,
|
||||||
|
|||||||
Reference in New Issue
Block a user