- src/pages/index.tsx +8 -4
src/pages/index.tsx
CHANGED
@@ -2,15 +2,19 @@ import Head from "next/head";
|
|
2 |
import Container from "@mui/material/Container";
|
3 |
import { Stack } from "@mui/material";
|
4 |
import { DividerBox } from "@/components/base/boxes";
|
5 |
-
import { useEffect, useState } from "react";
|
6 |
|
7 |
export default function Home() {
|
8 |
const [data, setData] = useState(0)
|
9 |
-
|
|
|
10 |
(async () => {
|
11 |
const res= (await ((await fetch('/api/get_file_list')).json()))
|
12 |
setData(res.file_list[0]);
|
13 |
-
})
|
|
|
|
|
|
|
14 |
}, [])
|
15 |
return (
|
16 |
<>
|
@@ -22,7 +26,7 @@ export default function Home() {
|
|
22 |
|
23 |
<Container component="main" sx={{ minHeight: "90vh" }}>
|
24 |
<Stack spacing={4} useFlexGap>
|
25 |
-
<
|
26 |
|
27 |
</Stack>
|
28 |
</Container>
|
|
|
2 |
import Container from "@mui/material/Container";
|
3 |
import { Stack } from "@mui/material";
|
4 |
import { DividerBox } from "@/components/base/boxes";
|
5 |
+
import { useCallback, useEffect, useState } from "react";
|
6 |
|
7 |
export default function Home() {
|
8 |
const [data, setData] = useState(0)
|
9 |
+
const update = useCallback(
|
10 |
+
|
11 |
(async () => {
|
12 |
const res= (await ((await fetch('/api/get_file_list')).json()))
|
13 |
setData(res.file_list[0]);
|
14 |
+
}), []
|
15 |
+
)
|
16 |
+
useEffect(() => {
|
17 |
+
update()
|
18 |
}, [])
|
19 |
return (
|
20 |
<>
|
|
|
26 |
|
27 |
<Container component="main" sx={{ minHeight: "90vh" }}>
|
28 |
<Stack spacing={4} useFlexGap>
|
29 |
+
<button style={{color: 'red'}} onClick={update}>{data}</button>
|
30 |
|
31 |
</Stack>
|
32 |
</Container>
|