-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
react1-week3/niloufar #274
base: main
Are you sure you want to change the base?
Conversation
const {data : initialTodo, error} = useSWR(url , fetcher); | ||
|
||
const [todos, setTodos] = useState<Todo[]>([]); | ||
const [isLoading, setIsLoading] = useState<boolean>(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can utilize the isLoading status directly from useSWR instead of creating a separate state for isLoading.
} | ||
}, [initialTodo]); | ||
|
||
const deleteTodo = (id: number) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest moving the deleteTodo function into the TodoList component as you're not depending on it out of the component scope.
setNewTodoItem({ ...newTodoItem, deadline: e.target.value }); | ||
}; | ||
|
||
const addNewTodo = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could add a condition to check if the new item is empty before adding it to the list. This prevents empty items from being included.
No description provided.