Skip to content

Commit

Permalink
tests for swr
Browse files Browse the repository at this point in the history
  • Loading branch information
jhlagado committed Feb 8, 2024
1 parent 23d9f79 commit 570740f
Show file tree
Hide file tree
Showing 30 changed files with 715 additions and 899 deletions.
437 changes: 436 additions & 1 deletion data/db.json

Large diffs are not rendered by default.

33 changes: 0 additions & 33 deletions src/components/MainPanel.test.tsx

This file was deleted.

30 changes: 2 additions & 28 deletions src/components/MainPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,15 @@
import { useState, useEffect } from "react";

Check failure on line 1 in src/components/MainPanel.tsx

View workflow job for this annotation

GitHub Actions / deploy

All imports in import declaration are unused.
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>
);
}
78 changes: 0 additions & 78 deletions src/components/todo/AddTodo/AddTodo.test.tsx

This file was deleted.

55 changes: 0 additions & 55 deletions src/components/todo/AddTodo/AddTodo.tsx

This file was deleted.

127 changes: 0 additions & 127 deletions src/components/todo/Home.test.tsx

This file was deleted.

22 changes: 0 additions & 22 deletions src/components/todo/Home.tsx

This file was deleted.

Loading

0 comments on commit 570740f

Please sign in to comment.