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

react_todo-app solution #773

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

react_todo-app solution #773

wants to merge 2 commits into from

Conversation

Medaed
Copy link

@Medaed Medaed commented Nov 14, 2023

<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.

we usually use classnames for such cases

src/App.tsx Outdated
Comment on lines 65 to 91
<>
<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}
/>

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
Comment on lines 52 to 59
<form onSubmit={handleFormSubmit}>
<input
type="text"
data-cy="createTodo"
className="new-todo"
placeholder="What needs to be done?"
value={query}
onChange={handleTitleChange}

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
Comment on lines 11 to 21
const todosContext = useContext(TodosContext);

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

Choose a reason for hiding this comment

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

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

@Medaed Medaed requested a review from etojeDenys November 15, 2023 11:45
Copy link

@IvanFesenko IvanFesenko 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. Please pay attention that mutating may make bad joke

Comment on lines +64 to +66

todo.title = newTodo;

Choose a reason for hiding this comment

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

Mutating is bad idea

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.

3 participants