-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
48 lines (40 loc) · 1.21 KB
/
index.html
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
<html>
<body>
<script type="module">
import {
createSignal,
onCleanup,
} from "https://cdn.skypack.dev/solid-js";
import { render } from "https://cdn.skypack.dev/solid-js/web";
import html from "https://cdn.skypack.dev/solid-js/html";
import {
useQuery,
useMutation,
useQueryClient,
QueryClient,
QueryClientProvider,
} from "https://unpkg.com/@tanstack/react-query@4/build/umd/index.production.js"
const App = () => {
const [count, setCount] = createSignal(0),
timer = setInterval(() => setCount(count() + 1), 1000);
onCleanup(() => clearInterval(timer));
const { isLoading, error, data } = useQuery({
queryKey: ['todos'],
queryFn: () =>
fetch('https://jsonplaceholder.typicode.com/todos/1').then(
(res) => res.json(),
),
})
if (isLoading) return html`<div>Loading...</div>`;
if (error) return html`<div>An error has occurred: ${error.message}</div>`;
return html`
<div>
<h1>{data.userId}</h1>
<p>{data.title}</p>
</div>
<div>${count}</div>`;
};
render(App, document.body);
</script>
</body>
</html>