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

add task solution #771

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mrogozhinskaya
Copy link

data-cy="toggleAll"
onChange={handlerCompleteAll}
/>
{todos.length !== 0 && (

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

Comment on lines 118 to 138
<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>

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

Choose a reason for hiding this comment

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

Suggested change
onFilterChange?: (filter: string) => void
onFilterChange: (filter: string) => void

why it can be undefined

Comment on lines 82 to 107
<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}
/>

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

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

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.

let's focus this input when I press double click
image

src/App.tsx Outdated
Comment on lines 157 to 159
const handleChangeTodoTitle = (event: string) => {
setIsEdited(event);
};

Choose a reason for hiding this comment

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

Suggested change
const handleChangeTodoTitle = (event: string) => {
setIsEdited(event);
};
const handleChangeTodoTitle = (title: string) => {
setIsEdited(title);
};

it's not the event

Comment on lines 36 to 63
<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)}

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

@mrogozhinskaya
Copy link
Author

DEMO LINK

@mrogozhinskaya
Copy link
Author

Done)

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.

good job

Comment on lines +20 to +21
return (
todos.length ? (

Choose a reason for hiding this comment

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

Suggested change
return (
todos.length ? (
if(todos.length) {
return null
}
return (

it looks much better (you can also move that condition in App.tsx)

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