0.1.0 #1
@@ -10,53 +10,53 @@
|
|||||||
|
|
||||||
import { Route as rootRouteImport } from './routes/__root'
|
import { Route as rootRouteImport } from './routes/__root'
|
||||||
import { Route as BlankRouteImport } from './routes/blank'
|
import { Route as BlankRouteImport } from './routes/blank'
|
||||||
import { Route as AsyncRenderingRouteImport } from './routes/async-rendering'
|
|
||||||
import { Route as IndexRouteImport } from './routes/index'
|
import { Route as IndexRouteImport } from './routes/index'
|
||||||
|
import { Route as DevAsyncRenderingRouteImport } from './routes/dev/async-rendering'
|
||||||
|
|
||||||
const BlankRoute = BlankRouteImport.update({
|
const BlankRoute = BlankRouteImport.update({
|
||||||
id: '/blank',
|
id: '/blank',
|
||||||
path: '/blank',
|
path: '/blank',
|
||||||
getParentRoute: () => rootRouteImport,
|
getParentRoute: () => rootRouteImport,
|
||||||
} as any)
|
} as any)
|
||||||
const AsyncRenderingRoute = AsyncRenderingRouteImport.update({
|
|
||||||
id: '/async-rendering',
|
|
||||||
path: '/async-rendering',
|
|
||||||
getParentRoute: () => rootRouteImport,
|
|
||||||
} as any)
|
|
||||||
const IndexRoute = IndexRouteImport.update({
|
const IndexRoute = IndexRouteImport.update({
|
||||||
id: '/',
|
id: '/',
|
||||||
path: '/',
|
path: '/',
|
||||||
getParentRoute: () => rootRouteImport,
|
getParentRoute: () => rootRouteImport,
|
||||||
} as any)
|
} as any)
|
||||||
|
const DevAsyncRenderingRoute = DevAsyncRenderingRouteImport.update({
|
||||||
|
id: '/dev/async-rendering',
|
||||||
|
path: '/dev/async-rendering',
|
||||||
|
getParentRoute: () => rootRouteImport,
|
||||||
|
} as any)
|
||||||
|
|
||||||
export interface FileRoutesByFullPath {
|
export interface FileRoutesByFullPath {
|
||||||
'/': typeof IndexRoute
|
'/': typeof IndexRoute
|
||||||
'/async-rendering': typeof AsyncRenderingRoute
|
|
||||||
'/blank': typeof BlankRoute
|
'/blank': typeof BlankRoute
|
||||||
|
'/dev/async-rendering': typeof DevAsyncRenderingRoute
|
||||||
}
|
}
|
||||||
export interface FileRoutesByTo {
|
export interface FileRoutesByTo {
|
||||||
'/': typeof IndexRoute
|
'/': typeof IndexRoute
|
||||||
'/async-rendering': typeof AsyncRenderingRoute
|
|
||||||
'/blank': typeof BlankRoute
|
'/blank': typeof BlankRoute
|
||||||
|
'/dev/async-rendering': typeof DevAsyncRenderingRoute
|
||||||
}
|
}
|
||||||
export interface FileRoutesById {
|
export interface FileRoutesById {
|
||||||
__root__: typeof rootRouteImport
|
__root__: typeof rootRouteImport
|
||||||
'/': typeof IndexRoute
|
'/': typeof IndexRoute
|
||||||
'/async-rendering': typeof AsyncRenderingRoute
|
|
||||||
'/blank': typeof BlankRoute
|
'/blank': typeof BlankRoute
|
||||||
|
'/dev/async-rendering': typeof DevAsyncRenderingRoute
|
||||||
}
|
}
|
||||||
export interface FileRouteTypes {
|
export interface FileRouteTypes {
|
||||||
fileRoutesByFullPath: FileRoutesByFullPath
|
fileRoutesByFullPath: FileRoutesByFullPath
|
||||||
fullPaths: '/' | '/async-rendering' | '/blank'
|
fullPaths: '/' | '/blank' | '/dev/async-rendering'
|
||||||
fileRoutesByTo: FileRoutesByTo
|
fileRoutesByTo: FileRoutesByTo
|
||||||
to: '/' | '/async-rendering' | '/blank'
|
to: '/' | '/blank' | '/dev/async-rendering'
|
||||||
id: '__root__' | '/' | '/async-rendering' | '/blank'
|
id: '__root__' | '/' | '/blank' | '/dev/async-rendering'
|
||||||
fileRoutesById: FileRoutesById
|
fileRoutesById: FileRoutesById
|
||||||
}
|
}
|
||||||
export interface RootRouteChildren {
|
export interface RootRouteChildren {
|
||||||
IndexRoute: typeof IndexRoute
|
IndexRoute: typeof IndexRoute
|
||||||
AsyncRenderingRoute: typeof AsyncRenderingRoute
|
|
||||||
BlankRoute: typeof BlankRoute
|
BlankRoute: typeof BlankRoute
|
||||||
|
DevAsyncRenderingRoute: typeof DevAsyncRenderingRoute
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module '@tanstack/react-router' {
|
declare module '@tanstack/react-router' {
|
||||||
@@ -68,13 +68,6 @@ declare module '@tanstack/react-router' {
|
|||||||
preLoaderRoute: typeof BlankRouteImport
|
preLoaderRoute: typeof BlankRouteImport
|
||||||
parentRoute: typeof rootRouteImport
|
parentRoute: typeof rootRouteImport
|
||||||
}
|
}
|
||||||
'/async-rendering': {
|
|
||||||
id: '/async-rendering'
|
|
||||||
path: '/async-rendering'
|
|
||||||
fullPath: '/async-rendering'
|
|
||||||
preLoaderRoute: typeof AsyncRenderingRouteImport
|
|
||||||
parentRoute: typeof rootRouteImport
|
|
||||||
}
|
|
||||||
'/': {
|
'/': {
|
||||||
id: '/'
|
id: '/'
|
||||||
path: '/'
|
path: '/'
|
||||||
@@ -82,13 +75,20 @@ declare module '@tanstack/react-router' {
|
|||||||
preLoaderRoute: typeof IndexRouteImport
|
preLoaderRoute: typeof IndexRouteImport
|
||||||
parentRoute: typeof rootRouteImport
|
parentRoute: typeof rootRouteImport
|
||||||
}
|
}
|
||||||
|
'/dev/async-rendering': {
|
||||||
|
id: '/dev/async-rendering'
|
||||||
|
path: '/dev/async-rendering'
|
||||||
|
fullPath: '/dev/async-rendering'
|
||||||
|
preLoaderRoute: typeof DevAsyncRenderingRouteImport
|
||||||
|
parentRoute: typeof rootRouteImport
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const rootRouteChildren: RootRouteChildren = {
|
const rootRouteChildren: RootRouteChildren = {
|
||||||
IndexRoute: IndexRoute,
|
IndexRoute: IndexRoute,
|
||||||
AsyncRenderingRoute: AsyncRenderingRoute,
|
|
||||||
BlankRoute: BlankRoute,
|
BlankRoute: BlankRoute,
|
||||||
|
DevAsyncRenderingRoute: DevAsyncRenderingRoute,
|
||||||
}
|
}
|
||||||
export const routeTree = rootRouteImport
|
export const routeTree = rootRouteImport
|
||||||
._addFileChildren(rootRouteChildren)
|
._addFileChildren(rootRouteChildren)
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
import { runtime } from "@/runtime"
|
|
||||||
import { Text } from "@radix-ui/themes"
|
|
||||||
import { createFileRoute } from "@tanstack/react-router"
|
|
||||||
import { Console, Effect } from "effect"
|
|
||||||
import { Component } from "effect-fc"
|
|
||||||
|
|
||||||
|
|
||||||
const RouteComponent = Component.make(function* AsyncRendering() {
|
|
||||||
console.log("render")
|
|
||||||
const VAsyncComponent = yield* Component.useSuspenseFC(AsyncComponent)
|
|
||||||
return <>
|
|
||||||
<Text>Route component</Text>
|
|
||||||
<VAsyncComponent />
|
|
||||||
</>
|
|
||||||
}).pipe(
|
|
||||||
Component.withRuntime(runtime.context)
|
|
||||||
)
|
|
||||||
|
|
||||||
const AsyncComponent = Component.make(function* AsyncComponent() {
|
|
||||||
yield* Console.log("rendering")
|
|
||||||
yield* Effect.sleep("500 millis")
|
|
||||||
return <Text>Rendered!</Text>
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
export const Route = createFileRoute("/async-rendering")({
|
|
||||||
component: RouteComponent
|
|
||||||
})
|
|
||||||
46
packages/example/src/routes/dev/async-rendering.tsx
Normal file
46
packages/example/src/routes/dev/async-rendering.tsx
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import { runtime } from "@/runtime"
|
||||||
|
import { Text, TextField } from "@radix-ui/themes"
|
||||||
|
import { createFileRoute } from "@tanstack/react-router"
|
||||||
|
import { GetRandomValues, makeUuid4 } from "@typed/id"
|
||||||
|
import { Console, Effect } from "effect"
|
||||||
|
import { Component, Hook } from "effect-fc"
|
||||||
|
import * as React from "react"
|
||||||
|
|
||||||
|
|
||||||
|
const RouteComponent = Component.make(function* AsyncRendering() {
|
||||||
|
const VAsyncComponent = yield* Component.useSuspenseFC(AsyncComponent)
|
||||||
|
const [input, setInput] = React.useState("")
|
||||||
|
|
||||||
|
return <>
|
||||||
|
<TextField.Root
|
||||||
|
value={input}
|
||||||
|
onChange={e => setInput(e.target.value)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<VAsyncComponent />
|
||||||
|
</>
|
||||||
|
}).pipe(
|
||||||
|
Component.withRuntime(runtime.context)
|
||||||
|
)
|
||||||
|
|
||||||
|
const AsyncComponent = Component.make(function* AsyncComponent() {
|
||||||
|
yield* Console.log("rendering")
|
||||||
|
|
||||||
|
const VSubComponent = yield* Component.useFC(SubComponent)
|
||||||
|
React.useState()
|
||||||
|
yield* Effect.sleep("500 millis")
|
||||||
|
|
||||||
|
return <>
|
||||||
|
<Text>Rendered!</Text><br />
|
||||||
|
<VSubComponent />
|
||||||
|
</>
|
||||||
|
})
|
||||||
|
|
||||||
|
const SubComponent = Component.make(function* SubComponent() {
|
||||||
|
const [state] = React.useState(yield* Hook.useOnce(() => Effect.provide(makeUuid4, GetRandomValues.CryptoRandom)))
|
||||||
|
return <Text>{state}</Text>
|
||||||
|
})
|
||||||
|
|
||||||
|
export const Route = createFileRoute("/dev/async-rendering")({
|
||||||
|
component: RouteComponent
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user