Skip to content

Commit 984acf6

Browse files
committed
updated
1 parent cfe59c7 commit 984acf6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/app/hydration-stream-suspense/list-users.tsx

+13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { User } from "../types";
44
import { useQuery } from "@tanstack/react-query";
55
import Image from "next/image";
6+
import React from "react";
67

78
async function getUsers() {
89
return (await fetch("https://jsonplaceholder.typicode.com/users").then(
@@ -11,15 +12,27 @@ async function getUsers() {
1112
}
1213

1314
export default function ListUsers() {
15+
const [count, setCount] = React.useState(0);
1416
const { data, isLoading, isFetching, error } = useQuery<User[]>({
1517
queryKey: ["stream-hydrate-users"],
1618
queryFn: () => getUsers(),
1719
suspense: true,
1820
staleTime: 5 * 1000,
1921
});
2022

23+
React.useEffect(() => {
24+
const intervalId = setInterval(() => {
25+
setCount((prev) => prev + 1);
26+
}, 100);
27+
28+
return () => {
29+
clearInterval(intervalId);
30+
};
31+
}, []);
32+
2133
return (
2234
<>
35+
<p>{count}</p>
2336
{error ? (
2437
<p>Oh no, there was an error</p>
2538
) : isFetching || isLoading ? (

0 commit comments

Comments
 (0)