Skip to content
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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

react1-week3/niloufar #274

wants to merge 5 commits into from

Conversation

Niloufar97
Copy link

No description provided.

@github-actions github-actions bot changed the title React1 week3/niloufar react1-week3/niloufar Mar 28, 2024
const {data : initialTodo, error} = useSWR(url , fetcher);

const [todos, setTodos] = useState<Todo[]>([]);
const [isLoading, setIsLoading] = useState<boolean>(true);
Copy link

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) => {
Copy link

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 = () => {
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants