-
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 #758
base: master
Are you sure you want to change the base?
add task solution #758
Conversation
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.
GJ 👍
Let's add a few small fixes (the main - a lot of lint disabling, why?)
src/contexts/TodosContext.tsx
Outdated
// eslint-disable-next-line | ||
export const TodoProvider = ({ children }: { children: React.ReactNode }) => { | ||
const [todos, setTodos] = useLocalStorage('todos', []); | ||
// eslint-disable-next-line |
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.
why did you disable eslint here? Don't do it w/o good reason - try to figure out with the problem instead
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.
not fixed
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.
but it's mean about line 22. that I was fixed.
src/contexts/TodosContext.tsx
Outdated
}); | ||
|
||
// eslint-disable-next-line | ||
export const TodoProvider = ({ children }: { children: React.ReactNode }) => { |
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 may use PropsWithChildren<{}>
type (import from 'react'
)
src/contexts/TodosContext.tsx
Outdated
case TodoActions.Completed: | ||
return todo.completed; | ||
default: | ||
return todo; |
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.
explicitly return boolean value - true
also, join TodoActions.All and default cases
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 isn't fixed
src/components/TodosFilter.tsx
Outdated
export const TodosFilter: React.FC = () => { | ||
const { selectedFilter, setSelectedFilter } = useContext(TodosContext); | ||
|
||
const TodoActionsToArr = useCallback((data: typeof TodoActions): string[] => { |
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 TodoActionsToArr = useCallback((data: typeof TodoActions): string[] => { | |
const todoActionsToArr = useCallback((data: typeof TodoActions): string[] => { |
camelCase for function names
but you don't need it at all - just use Object.values(TodoActions)
w/o memorization (this process also need some resources etc.) or at least return Object.values(TodoActions)
from useMemo callback
src/components/TodosFilter.tsx
Outdated
const TodoActionsToArr = useCallback((data: typeof TodoActions): string[] => { | ||
return Object.values(data); | ||
}, []); | ||
// eslint-disable-next-line |
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.
why disabled?
src/components/TodoItem.tsx
Outdated
setIsEditing(false); | ||
}; | ||
|
||
const handleOnBlur = () => { |
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 handleOnBlur = () => { | |
const handleBlur = () => { |
import React, { useContext } from 'react'; | ||
import { TodosContext } from '../contexts/TodosContext'; | ||
|
||
export const ClearCompletedButton: React.FC = () => { |
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's the very small component you could keep in the Footer.tsx - just FYI
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 should fix all the comments before requesting new review, if you have any questions ask them in fe_chat
src/contexts/TodosContext.tsx
Outdated
case TodoActions.Completed: | ||
return todo.completed; | ||
default: | ||
return todo; |
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 isn't fixed
src/contexts/TodosContext.tsx
Outdated
// eslint-disable-next-line | ||
export const TodoProvider = ({ children }: { children: React.ReactNode }) => { | ||
const [todos, setTodos] = useLocalStorage('todos', []); | ||
// eslint-disable-next-line |
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.
not fixed
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.
Much better! Well done!
DEMO LINK