-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
👉🏻Develop👌🏻 #752
base: master
Are you sure you want to change the base?
👉🏻Develop👌🏻 #752
Conversation
const todosContext = useContext(TodosContext); | ||
|
||
const { | ||
todos, | ||
addTodo, | ||
deleteCompletedTodos, | ||
handleToggleAll, | ||
todoCount, | ||
completedTodos, | ||
filterTodos, | ||
} = todosContext; |
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 do it directly
const todosContext = useContext(TodosContext); | |
const { | |
todos, | |
addTodo, | |
deleteCompletedTodos, | |
handleToggleAll, | |
todoCount, | |
completedTodos, | |
filterTodos, | |
} = todosContext; | |
const { | |
todos, | |
addTodo, | |
deleteCompletedTodos, | |
handleToggleAll, | |
todoCount, | |
completedTodos, | |
filterTodos, | |
} = useContext(TodosContext); |
src/components/TodosContext.tsx
Outdated
useEffect(() => { | ||
const storedTodos = localStorage.getItem('todos'); | ||
|
||
if (storedTodos) { | ||
setTodos(JSON.parse(storedTodos)); | ||
} | ||
}, []); | ||
|
||
useEffect(() => { | ||
localStorage.setItem('todos', JSON.stringify(todos)); | ||
}, [todos]); | ||
|
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.
actually, you can move this logic to useLocaleStrorage hook, it will simplify the logic
<li> | ||
<a | ||
href="#/active" | ||
className={filter === 'active' ? 'selected' : ''} |
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.
we usually use classnames for such cases
src/components/TodoFilter.tsx
Outdated
<li> | ||
<a | ||
href="#/" | ||
className={filter === 'all' ? 'selected' : ''} |
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.
className={filter === 'all' ? 'selected' : ''} | |
className={filter === Filter.All ? 'selected' : ''} |
src/components/TodoFilter.tsx
Outdated
<a | ||
href="#/" | ||
className={filter === 'all' ? 'selected' : ''} |
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.
also, I suggest you can create some links array and render them in the loop(using the .map)
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.
GJ
https://denys2.github.io/react_todo-app/