-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
715 additions
and
899 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,15 @@ | ||
import { useState, useEffect } from "react"; | ||
import TodoList from "./xtodo/TodoList"; | ||
|
||
export const TODOS_URL = "https://dummyjson.com/todos"; | ||
|
||
import {preload} from 'swr' | ||
import { SERVER_URL as cacheKey, getTodos} from "./xtodo/todosAPI"; | ||
import { preload } from "swr"; | ||
import { SERVER_URL as cacheKey, getTodos } from "./xtodo/todosApi"; | ||
|
||
preload(cacheKey, getTodos); | ||
|
||
|
||
export default function MainPanel() { | ||
const [count, setCount] = useState(0); | ||
const [todos, setTodos] = useState([]); | ||
|
||
useEffect(() => { | ||
fetch(TODOS_URL) | ||
.then(async (res) => await res.json()) | ||
.then((res) => { | ||
setTodos(res.todos); | ||
}) | ||
.catch(console.log); | ||
}, []); | ||
|
||
return ( | ||
<div className="p-4"> | ||
{/* <Home /> */} | ||
<TodoList /> | ||
<div className="text-green-500">Todo list: {todos.length}</div> | ||
<label htmlFor="inc">Inc</label> | ||
<button | ||
id="inc" | ||
onClick={() => { | ||
setCount((count) => count + 1); | ||
}} | ||
> | ||
count is {count} | ||
</button> | ||
</div> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.