0.1.0 #1

Merged
Thilawyn merged 81 commits from next into master 2025-07-17 21:17:57 +02:00
2 changed files with 7 additions and 6 deletions
Showing only changes of commit 5aa5c28465 - Show all commits

View File

@@ -1,4 +1,4 @@
import { Context, Effect, type Equivalence, ExecutionStrategy, Function, Pipeable, Runtime, Scope, String, Tracer, type Utils } from "effect"
import { Context, Effect, type Equivalence, ExecutionStrategy, Function, Pipeable, Predicate, Runtime, Scope, String, Tracer, type Utils } from "effect"
import * as React from "react"
import * as Hook from "./Hook.js"
import type { ExcludeKeys } from "./utils.js"
@@ -111,7 +111,9 @@ export const useFC: {
self: Component<E, R, P>
): Effect.Effect<React.FC<P>, never, Exclude<R, Scope.Scope>>
} = Effect.fn("useFC")(function* <E, R, P extends {}>(
self: Component<E, R, P>
self:
| Component<E, R, P> & Memoized<P>
| Component<E, R, P>
) {
const runtimeRef = React.useRef<Runtime.Runtime<Exclude<R, Scope.Scope>>>(null!)
runtimeRef.current = yield* Effect.runtime<Exclude<R, Scope.Scope>>()
@@ -129,7 +131,9 @@ export const useFC: {
Effect.provideService(self.body(props), Scope.Scope, scope)
)
f.displayName = self.displayName ?? "Anonymous"
return f
return Predicate.hasProperty(self, "memo")
? React.memo(f, self.propsAreEqual)
: f
}, [scope])
return React.createElement(FC, props)

View File

@@ -111,6 +111,3 @@ export const Todo = Component.make(function* Todo(props: TodoProps) {
</Flex>
)
})
const MemoizedTodo = Component.memo(Todo)
const MemoizedTodo2 = Component.memo(MemoizedTodo)