Fix example
Lint / lint (push) Failing after 41s

This commit is contained in:
Julien Valverdé
2026-07-23 04:36:31 +02:00
parent 296f65ee1b
commit 3a25b1a34e
4 changed files with 18 additions and 78 deletions
+15 -2
View File
@@ -1,11 +1,19 @@
import { Container, Flex, Heading, Slider, Text, TextField } from "@radix-ui/themes"
import { createFileRoute } from "@tanstack/react-router"
import { Console, Effect } from "effect"
import { Async, Component, Memoized } from "effect-fc-next"
import * as React from "react"
import { fetchPost } from "@/post"
import { runtime } from "@/runtime"
const fetchPost = (id: number) => Effect.sleep("500 millis").pipe(
Effect.as({
title: `Post ${id}`,
body: `This is the content of post ${id}.`,
}),
)
interface AsyncFetchPostViewProps {
readonly id: number
}
@@ -13,6 +21,11 @@ interface AsyncFetchPostViewProps {
const AsyncFetchPostView = Component.make("AsyncFetchPostView")(function*(
props: AsyncFetchPostViewProps,
) {
yield* Component.useOnMount(() => Effect.gen(function*() {
yield* Effect.addFinalizer(() => Console.log("AsyncFetchPostView unmounted"))
yield* Console.log("AsyncFetchPostView mounted")
}))
const post = yield* Component.useOnChange(
() => fetchPost(props.id),
[props.id],
@@ -51,7 +64,7 @@ const AsyncRouteComponent = Component.make("AsyncRouteView")(function*() {
onValueChange={([value]) => setId(value ?? 1)}
/>
<AsyncFetchPost id={id} fallback={<Text>Loading post...</Text>} />
<AsyncFetchPost id={id} />
</Flex>
</Container>
)