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

👉🏻Develop👌🏻 #752

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

👉🏻Develop👌🏻 #752

wants to merge 4 commits into from

Conversation

denys2
Copy link

@denys2 denys2 commented Oct 29, 2023

Comment on lines +11 to +21
const todosContext = useContext(TodosContext);

const {
todos,
addTodo,
deleteCompletedTodos,
handleToggleAll,
todoCount,
completedTodos,
filterTodos,
} = todosContext;

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

Suggested change
const todosContext = useContext(TodosContext);
const {
todos,
addTodo,
deleteCompletedTodos,
handleToggleAll,
todoCount,
completedTodos,
filterTodos,
} = todosContext;
const {
todos,
addTodo,
deleteCompletedTodos,
handleToggleAll,
todoCount,
completedTodos,
filterTodos,
} = useContext(TodosContext);

Comment on lines 89 to 100
useEffect(() => {
const storedTodos = localStorage.getItem('todos');

if (storedTodos) {
setTodos(JSON.parse(storedTodos));
}
}, []);

useEffect(() => {
localStorage.setItem('todos', JSON.stringify(todos));
}, [todos]);

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' : ''}

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

<li>
<a
href="#/"
className={filter === 'all' ? 'selected' : ''}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
className={filter === 'all' ? 'selected' : ''}
className={filter === Filter.All ? 'selected' : ''}

Comment on lines 17 to 19
<a
href="#/"
className={filter === 'all' ? 'selected' : ''}

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)

@denys2 denys2 closed this Dec 18, 2023
@denys2 denys2 reopened this Dec 18, 2023
@denys2 denys2 requested a review from etojeDenys December 18, 2023 14:03
Copy link

@etojeDenys etojeDenys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GJ

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.

2 participants