File tree 3 files changed +16
-15
lines changed
examples/tanstack-start/src
3 files changed +16
-15
lines changed Original file line number Diff line number Diff line change
1
+ import { createServerFn } from "@tanstack/react-start"
2
+
3
+ export const personServerFn = createServerFn ( { method : "GET" } )
4
+ . validator ( ( d : string ) => d )
5
+ . handler ( ( { data : name } ) => {
6
+ return { name, randomNumber : Math . floor ( Math . random ( ) * 100 ) }
7
+ } )
8
+
9
+ export const slowServerFn = createServerFn ( { method : "GET" } )
10
+ . validator ( ( d : string ) => d )
11
+ . handler ( async ( { data : name } ) => {
12
+ await new Promise ( ( r ) => setTimeout ( r , 1000 ) )
13
+ return { name, randomNumber : Math . floor ( Math . random ( ) * 100 ) }
14
+ } )
Original file line number Diff line number Diff line change 1
1
import { Trans } from "@lingui/react/macro"
2
2
import { Await , createFileRoute } from "@tanstack/react-router"
3
- import { createServerFn } from "@tanstack/react-start"
4
3
import { Suspense , useState } from "react"
5
-
6
- const personServerFn = createServerFn ( { method : "GET" } )
7
- . validator ( ( d : string ) => d )
8
- . handler ( ( { data : name } ) => {
9
- return { name, randomNumber : Math . floor ( Math . random ( ) * 100 ) }
10
- } )
11
-
12
- const slowServerFn = createServerFn ( { method : "GET" } )
13
- . validator ( ( d : string ) => d )
14
- . handler ( async ( { data : name } ) => {
15
- await new Promise ( ( r ) => setTimeout ( r , 1000 ) )
16
- return { name, randomNumber : Math . floor ( Math . random ( ) * 100 ) }
17
- } )
4
+ import { personServerFn , slowServerFn } from "~/functions/deferred"
18
5
19
6
export const Route = createFileRoute ( "/deferred" ) ( {
20
7
loader : async ( ) => {
Original file line number Diff line number Diff line change
1
+ import { i18n } from "@lingui/core"
1
2
import { Trans } from "@lingui/react/macro"
2
3
import { createFileRoute } from "@tanstack/react-router"
3
4
import axios from "redaxios"
4
5
import type { User } from "~/utils/users"
5
6
import { DEPLOY_URL } from "~/utils/users"
6
7
import { NotFound } from "~/components/NotFound"
7
8
import { UserErrorComponent } from "~/components/UserError"
8
- import { i18n } from "@lingui/core"
9
9
10
10
export const Route = createFileRoute ( "/users/$userId" ) ( {
11
11
loader : async ( { params : { userId } } ) => {
You can’t perform that action at this time.
0 commit comments