4b712de788
## Summary - Rename `effect-fc-next` to `effect-view` and update package metadata, internal symbols, imports, and repository references. - Promote the Effect 4 example to `packages/example` and move the legacy Effect 3 example to `packages/effect-fc-example`. - Add `effect-view` to the npm publishing workflow. - Update the Vite Fast Refresh plugin for `effect-view` and rename `effectViewPlugin()` to `effectView()`. - Upgrade Effect, React, TypeScript, build tooling, and related dependencies. - Refresh the documentation and homepage. ## Documentation - Add a dedicated Async guide covering: - Suspense fallbacks - Hook ordering - Memoization - Structural prop equality - Clarify synchronous and asynchronous component behavior. - Document runner scope and service requirements. - Explain stable construction of Query, Mutation, and Form instances. - Expand focused Lens and Form examples, including curried focus helpers. - Document the optional `@effect/platform-browser` dependency for window-focus query refresh. - Improve the Forms guide structure and examples. - Fix responsive homepage headline wrapping and update homepage copy. ## Notable API changes - Package rename: ```diff - effect-fc-next + effect-view --------- Co-authored-by: Julien Valverdé <julien.valverde@mailo.com> Reviewed-on: #59
43 lines
1.5 KiB
TypeScript
43 lines
1.5 KiB
TypeScript
import { Container, Flex, Text, TextField } from "@radix-ui/themes"
|
|
import { createFileRoute } from "@tanstack/react-router"
|
|
import { Console, Effect } from "effect"
|
|
import { Component } from "effect-fc"
|
|
import * as React from "react"
|
|
import { runtime } from "@/runtime"
|
|
|
|
|
|
class SubService extends Effect.Service<SubService>()("SubService", {
|
|
effect: (value: string) => Effect.succeed({ value })
|
|
}) {}
|
|
|
|
const SubComponent = Component.makeUntraced("SubComponent")(function*() {
|
|
const service = yield* SubService
|
|
yield* Component.useOnMount(() => Effect.gen(function*() {
|
|
yield* Effect.addFinalizer(() => Console.log("SubComponent unmounted"))
|
|
yield* Console.log("SubComponent mounted")
|
|
}))
|
|
|
|
return <Text>{service.value}</Text>
|
|
})
|
|
|
|
const ContextView = Component.makeUntraced("ContextView")(function*() {
|
|
const [serviceValue, setServiceValue] = React.useState("test")
|
|
const SubServiceLayer = React.useMemo(() => SubService.Default(serviceValue), [serviceValue])
|
|
const SubComponentFC = yield* Effect.provide(SubComponent.use, yield* Component.useLayer(SubServiceLayer))
|
|
|
|
return (
|
|
<Container>
|
|
<Flex direction="column" align="center">
|
|
<TextField.Root value={serviceValue} onChange={e => setServiceValue(e.target.value)} />
|
|
<SubComponentFC />
|
|
</Flex>
|
|
</Container>
|
|
)
|
|
}).pipe(
|
|
Component.withRuntime(runtime.context)
|
|
)
|
|
|
|
export const Route = createFileRoute("/dev/context")({
|
|
component: ContextView
|
|
})
|