import { Box, TextField } from "@radix-ui/themes" import { createFileRoute } from "@tanstack/react-router" import { Console, Effect, Layer, pipe, SubscriptionRef } from "effect" import { ReactComponent, ReactHook, ReactManagedRuntime } from "effect-components" import * as React from "react" class TestService extends Effect.Service()("TestService", { effect: Effect.bind(Effect.Do, "ref", () => SubscriptionRef.make("value")), }) {} const runtime = ReactManagedRuntime.make(Layer.empty) export const Route = createFileRoute("/effect-component-tests")({ component: RouteComponent, }) function RouteComponent() { return ( ) } const MyRoute = pipe( Effect.fn(function*() { return yield* ReactComponent.use(MyTestComponent, C => ) }), ReactComponent.withDisplayName("MyRoute"), ReactComponent.withRuntime(runtime.context), ) const MyTestComponent = pipe( Effect.fn(function*() { const [state, setState] = React.useState("value") yield* ReactHook.useEffect(() => Effect.andThen( Effect.addFinalizer(() => Console.log("MyTestComponent umounted")), Console.log("MyTestComponent mounted"), ), []) return <> setState(e.target.value)} /> }), ReactComponent.withDisplayName("MyTestComponent"), )