-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.tsx
38 lines (31 loc) · 928 Bytes
/
index.tsx
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
import Head from "next/head";
import Image from "next/image";
import { Inter } from "next/font/google";
import styles from "@/styles/Home.module.css";
import { useModuleImportSuspense } from "./module/useModuleImport";
import { Suspense, useCallback, useRef } from "react";
const inter = Inter({ subsets: ["latin"] });
const TestComponent = () => {
const stateCheck = useRef(false);
console.log("HELLO THERE --->", stateCheck.current);
if (!stateCheck.current) {
stateCheck.current = true;
}
const callback = useCallback(
() => [
new Promise((resolve) => resolve({ Test: () => "Test" })) as Promise<{
Test: () => string;
}>,
],
[]
);
const [state] = useModuleImportSuspense(callback);
return <div>Test {state.Test()} </div>;
};
export default function Home() {
return (
<Suspense fallback={<div>Loading...</div>}>
<TestComponent />
</Suspense>
);
}