-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 #1063
base: master
Are you sure you want to change the base?
Solution #1063
Conversation
RostyslavSharuiev
commented
Oct 12, 2024
- DEMO LINK
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/components/Footer/Footer.tsx
Outdated
const completedTodosCount = todos.filter(todo => todo.completed).length; | ||
const uncompletedTodos = todos.filter(todo => !todo.completed); |
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.
use useMemo
src/components/Footer/Footer.tsx
Outdated
onClick={() => | ||
dispatch({ type: 'setFilter', payload: filterTitle }) | ||
} |
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.
create a handle function for this logic
})} | ||
onDoubleClick={() => setIsEditing(true)} | ||
> | ||
<label className="todo__status-label"> |
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.
label
element should be associated with a form control.
To fix this, you should use the htmlFor
attribute on the label
to associate it with the checkbox input.
src/components/TodoItem/TodoItem.tsx
Outdated
// else { | ||
// document.addEventListener('keyup', handleKeyUp); | ||
// } |
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.
Lets make your code clean, remove committed code.
src/index.tsx
Outdated
// import './styles/todo-list.scss'; | ||
// import './styles/filters.scss'; |
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.
remove committed code.
src/components/TodoItem/TodoItem.tsx
Outdated
const handleKeyUp = (event: KeyboardEvent) => { | ||
if (event.key === 'Escape') { | ||
setIsEditing(false); | ||
setTitle(todo.title); | ||
} else if (event.key === 'Enter') { | ||
handleTitleSave(); | ||
} | ||
}; |
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 'handleKeyUp' function makes the dependencies of useEffect Hook change on every render. Alternatively, wrap the definition of 'handleKeyUp' in its own useCallback() Hook
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.
Well done 🔥