0.1.0 #1
@@ -1,5 +1,5 @@
|
|||||||
import { runtime } from "@/runtime"
|
import { runtime } from "@/runtime"
|
||||||
import { Text, TextField } from "@radix-ui/themes"
|
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 { Console, Effect } from "effect"
|
import { Console, Effect } from "effect"
|
||||||
@@ -8,17 +8,21 @@ import * as React from "react"
|
|||||||
|
|
||||||
|
|
||||||
const RouteComponent = Component.make(function* AsyncRendering() {
|
const RouteComponent = Component.make(function* AsyncRendering() {
|
||||||
|
const VMemoizedAsyncComponent = yield* Component.useFC(MemoizedAsyncComponent)
|
||||||
const VAsyncComponent = yield* Component.useFC(AsyncComponent)
|
const VAsyncComponent = yield* Component.useFC(AsyncComponent)
|
||||||
const [input, setInput] = React.useState("")
|
const [input, setInput] = React.useState("")
|
||||||
|
|
||||||
return <>
|
return (
|
||||||
|
<Flex direction="column" align="stretch" gap="2">
|
||||||
<TextField.Root
|
<TextField.Root
|
||||||
value={input}
|
value={input}
|
||||||
onChange={e => setInput(e.target.value)}
|
onChange={e => setInput(e.target.value)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<VMemoizedAsyncComponent />
|
||||||
<VAsyncComponent />
|
<VAsyncComponent />
|
||||||
</>
|
</Flex>
|
||||||
|
)
|
||||||
}).pipe(
|
}).pipe(
|
||||||
Component.withRuntime(runtime.context)
|
Component.withRuntime(runtime.context)
|
||||||
)
|
)
|
||||||
@@ -27,16 +31,18 @@ const AsyncComponent = Component.make(function* AsyncComponent() {
|
|||||||
yield* Console.log("rendering")
|
yield* Console.log("rendering")
|
||||||
|
|
||||||
const VSubComponent = yield* Component.useFC(SubComponent)
|
const VSubComponent = yield* Component.useFC(SubComponent)
|
||||||
React.useState()
|
|
||||||
yield* Effect.sleep("500 millis")
|
yield* Effect.sleep("500 millis")
|
||||||
|
|
||||||
return <>
|
return (
|
||||||
<Text>Rendered!</Text><br />
|
<Flex direction="column" align="stretch">
|
||||||
|
<Text>Rendered!</Text>
|
||||||
<VSubComponent />
|
<VSubComponent />
|
||||||
</>
|
</Flex>
|
||||||
|
)
|
||||||
}).pipe(
|
}).pipe(
|
||||||
Component.suspense
|
Component.suspense
|
||||||
)
|
)
|
||||||
|
const MemoizedAsyncComponent = Component.memo(AsyncComponent)
|
||||||
|
|
||||||
const SubComponent = Component.make(function* SubComponent() {
|
const SubComponent = Component.make(function* SubComponent() {
|
||||||
const [state] = React.useState(yield* Hook.useOnce(() => Effect.provide(makeUuid4, GetRandomValues.CryptoRandom)))
|
const [state] = React.useState(yield* Hook.useOnce(() => Effect.provide(makeUuid4, GetRandomValues.CryptoRandom)))
|
||||||
|
|||||||
Reference in New Issue
Block a user