-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest-serverFn.tsx
More file actions
45 lines (40 loc) · 1.04 KB
/
test-serverFn.tsx
File metadata and controls
45 lines (40 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { createFileRoute } from '@tanstack/react-router';
import { createServerFn } from '@tanstack/react-start';
import { startSpan } from '@sentry/tanstackstart-react';
const testLog = createServerFn().handler(async () => {
console.log('Test log from server function');
return { message: 'Log created' };
});
const testNestedLog = createServerFn().handler(async () => {
await startSpan({ name: 'testNestedLog' }, async () => {
await testLog();
});
console.log('Outer test log from server function');
return { message: 'Nested log created' };
});
export const Route = createFileRoute('/test-serverFn')({
component: TestLog,
});
function TestLog() {
return (
<div>
<h1>Test Log Page</h1>
<button
type="button"
onClick={async () => {
await testLog();
}}
>
Call server function
</button>
<button
type="button"
onClick={async () => {
await testNestedLog();
}}
>
Call server function nested
</button>
</div>
);
}