-
-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathroot.tsx
More file actions
70 lines (63 loc) · 1.69 KB
/
root.tsx
File metadata and controls
70 lines (63 loc) · 1.69 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import {
ActionFunctionArgs,
data,
Form,
Links,
LoaderFunctionArgs,
Meta,
Outlet,
Scripts,
ScrollRestoration,
} from "react-router";
import { userSomething } from "./modules/user.server";
export const links = () => [];
export const loader = ({context, devTools }: LoaderFunctionArgs) => {
userSomething();
const mainPromise = new Promise((resolve, reject) => {
setTimeout(() => {
const subPromise = new Promise((resolve, reject) => {
setTimeout(() => {
resolve("test");
}, 2000);
});
resolve({ test: "test", subPromise});
}, 2000);
});
const start =devTools?.tracing.start("test")!;
devTools?.tracing.end("test", start);
return data({ message: "Hello World", mainPromise, bigInt: BigInt(10) }, { headers: { "Cache-Control": "max-age=3600, private" } });
}
export const action =async ({devTools}: ActionFunctionArgs) => {
const start = devTools?.tracing.start("action submission")
await new Promise((resolve, reject) => {
setTimeout(() => {
resolve("test");
}, 2000);
});
devTools?.tracing.end("action submission", start!)
return ({ message: "Hello World", bigInt: BigInt(10) });
}
function App() {
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<Meta />
<Links />
</head>
<body>
<Form method="post">
<input readOnly type="text" name="name" value={"name"} />
<button type="submit">
Submit
</button>
</Form>
<Outlet />
<ScrollRestoration />
<Scripts />
</body>
</html>
);
}
export { App as default }