-
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
add task solution #771
base: master
Are you sure you want to change the base?
add task solution #771
Conversation
src/Components/TodoApp/TodoApp.tsx
Outdated
data-cy="toggleAll" | ||
onChange={handlerCompleteAll} | ||
/> | ||
{todos.length !== 0 && ( |
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.
this condition looks redundant, 'cause you have the same above
src/Components/TodoApp/TodoApp.tsx
Outdated
<footer className="footer"> | ||
<span className="todo-count" data-cy="todosCounter"> | ||
{`${noCompleteTodos.length} items left`} | ||
</span> | ||
|
||
<TodosFilter | ||
currentFilter={filter} | ||
onFilterChange={handlerFilterChange} | ||
/> | ||
|
||
{isSomeComplete && ( | ||
<button | ||
type="button" | ||
className="clear-completed" | ||
onClick={handlerClearCompletes} | ||
> | ||
Clear completed | ||
</button> | ||
)} | ||
|
||
</footer> |
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.
let's create the separate Footer component
|
||
type Props = { | ||
currentFilter: string, | ||
onFilterChange?: (filter: string) => void |
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.
onFilterChange?: (filter: string) => void | |
onFilterChange: (filter: string) => void |
why it can be undefined
src/Components/TodoApp/TodoApp.tsx
Outdated
<form | ||
onSubmit={handlerAddTodo} | ||
onBlur={handlerAddTodo} | ||
> | ||
<input | ||
type="text" | ||
data-cy="createTodo" | ||
className="new-todo" | ||
placeholder="What needs to be done?" | ||
value={title} | ||
onChange={handlerChangeTitle} | ||
/> | ||
</form> | ||
</header> | ||
|
||
{todos.length !== 0 && ( | ||
<section className="main"> | ||
|
||
<input | ||
checked={allCompleted} | ||
type="checkbox" | ||
id="toggle-all" | ||
className="toggle-all" | ||
data-cy="toggleAll" | ||
onChange={handlerCompleteAll} | ||
/> |
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 also create the separate component for form with header
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.
it should improve the readability and performance in App.tsx
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.
src/App.tsx
Outdated
const handleChangeTodoTitle = (event: string) => { | ||
setIsEdited(event); | ||
}; |
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 handleChangeTodoTitle = (event: string) => { | |
setIsEdited(event); | |
}; | |
const handleChangeTodoTitle = (title: string) => { | |
setIsEdited(title); | |
}; |
it's not the event
src/сomponents/TodoList/TodoList.tsx
Outdated
<li | ||
className={cn({ | ||
completed: todo.completed, | ||
editing: todo.title === edit, | ||
})} | ||
key={todo.id} | ||
onDoubleClick={() => { | ||
onEdit(todo.title); | ||
setCurrInputValue(todo.title); | ||
}} | ||
> | ||
<div className="view"> | ||
<input | ||
type="checkbox" | ||
className="toggle" | ||
id={`${todo.id}`} | ||
checked={todo.completed} | ||
onChange={() => onChange(todo.id)} | ||
/> | ||
<label> | ||
{todo.title} | ||
</label> | ||
<button | ||
type="button" | ||
aria-label="destroy" | ||
className="destroy" | ||
data-cy="deleteTodo" | ||
onClick={() => onDelete(todo.id)} |
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.
my suggestion to you is that it will be better to create the TodoItem component and move a big part of the logic from the app. tsx to that component.
It should improve the readability by at least
9657b38
to
e7bc878
Compare
Done) |
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
return ( | ||
todos.length ? ( |
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.
return ( | |
todos.length ? ( | |
if(todos.length) { | |
return null | |
} | |
return ( |
it looks much better (you can also move that condition in App.tsx)
DEMO LINK