-
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
react_todo-app solution #773
base: master
Are you sure you want to change the base?
Conversation
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.
we usually use classnames for such cases
src/App.tsx
Outdated
<> | ||
<section className="main"> | ||
<input | ||
type="checkbox" | ||
id="toggle-all" | ||
className="toggle-all" | ||
data-cy="toggleAll" | ||
onClick={toggleCompletionOfAllTodos} | ||
/> | ||
<label htmlFor="toggle-all">Mark all as complete</label> | ||
|
||
<Todolist | ||
todos={filteredTodos} | ||
/> | ||
</section> | ||
|
||
<footer className="footer" data-cy="todosFilter"> | ||
<span className="todo-count" data-cy="todosCounter"> | ||
{todoCount === 1 | ||
? `${todoCount} item left` | ||
: `${todoCount} items left`} | ||
</span> | ||
|
||
<TodoFilter | ||
filter={filter} | ||
setFilter={setFilter} | ||
/> |
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 create separate components for this, to simplify App.tsx
src/App.tsx
Outdated
<form onSubmit={handleFormSubmit}> | ||
<input | ||
type="text" | ||
data-cy="createTodo" | ||
className="new-todo" | ||
placeholder="What needs to be done?" | ||
value={query} | ||
onChange={handleTitleChange} |
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.
the same with this
src/App.tsx
Outdated
const todosContext = useContext(TodosContext); | ||
|
||
const { | ||
todos, | ||
addTodo, | ||
deleteCompletedTodos, | ||
toggleCompletionOfAllTodos, | ||
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.
const todosContext = useContext(TodosContext); | |
const { | |
todos, | |
addTodo, | |
deleteCompletedTodos, | |
toggleCompletionOfAllTodos, | |
todoCount, | |
completedTodos, | |
filterTodos, | |
} = todosContext; | |
const { | |
todos, | |
addTodo, | |
deleteCompletedTodos, | |
toggleCompletionOfAllTodos, | |
todoCount, | |
completedTodos, | |
filterTodos, | |
} = useContext(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.
Good job. Please pay attention that mutating may make bad joke
|
||
todo.title = newTodo; | ||
|
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.
Mutating is bad idea
DEMO LINK