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

solution #1559

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

solution #1559

wants to merge 2 commits into from

Conversation

yuliiazubenko
Copy link

Comment on lines +46 to +57
const activeTodosCount = useMemo(
() => todos.filter(todo => !todo.completed).length,
[todos],
);
const completedTodosCount = useMemo(
() => todos.filter(todo => todo.completed).length,
[todos],
);
const areAllTodosCompleted = useMemo(
() => todos.every(todo => todo.completed),
[todos],
);

Choose a reason for hiding this comment

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

these three functions will work without useMemo, but they are also very good there

placeholder="What needs to be done?"
ref={inputRef}
value={inputValue}
onChange={event => setInputValue(event.target.value)}

Choose a reason for hiding this comment

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

put it in a separate function

className="todo__title-field"
placeholder="Empty todo will be deleted"
value={todoTitleValue}
onChange={event => setTodoTitleValue(event.target.value)}

Choose a reason for hiding this comment

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

also create separate function

tempTodo: Todo | null;
loadingTodoIds: number[];
onRemoveTodo: (todoId: number) => Promise<void>;
onUpdateTodo: (todo: Todo) => Promise<void>;

Choose a reason for hiding this comment

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

you sould change all functions that start with "on"

exmaple:

onUpdateTodo: (todo: Todo) => Promise<void>;
to
handleUpdateTodo: (todo: Todo) => Promise<void>;

Choose a reason for hiding this comment

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

you sould change all functions that start with "on"

exmaple:

onUpdateTodo: (todo: Todo) => Promise<void>; to handleUpdateTodo: (todo: Todo) => Promise<void>;

No, when you pass handlers as props they should start from on
https://javascript.plainenglish.io/handy-naming-conventions-for-event-handler-functions-props-in-react-fc1cbb791364

Copy link

@Eeoneishin Eeoneishin 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, can you fix some comments and also remove all comments

Copy link

@BudnikOleksii BudnikOleksii left a comment

Choose a reason for hiding this comment

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

Good work 👍

src/App.tsx Outdated
Comment on lines 34 to 36
if (filterStatus === FilterStatus.All) {
return true;
}

Choose a reason for hiding this comment

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

You don't need to filter at all when filterStatus === FilterStatus.All

tempTodo: Todo | null;
loadingTodoIds: number[];
onRemoveTodo: (todoId: number) => Promise<void>;
onUpdateTodo: (todo: Todo) => Promise<void>;

Choose a reason for hiding this comment

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

you sould change all functions that start with "on"

exmaple:

onUpdateTodo: (todo: Todo) => Promise<void>; to handleUpdateTodo: (todo: Todo) => Promise<void>;

No, when you pass handlers as props they should start from on
https://javascript.plainenglish.io/handy-naming-conventions-for-event-handler-functions-props-in-react-fc1cbb791364

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