-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 #1527
base: master
Are you sure you want to change the base?
add task solution #1527
Conversation
src/App.tsx
Outdated
|
||
export const App: React.FC = () => { | ||
// #region variables | ||
|
||
const [value, setValue] = useState<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.
it's redundant to specify types for primitives
const [value, setValue] = useState<string>(''); | |
const [value, setValue] = useState(''); |
src/App.tsx
Outdated
useEffect(() => { | ||
if (completedTodos.length > 0 && completedTodos.length === todos.length) { | ||
setAllCompleted(true); | ||
} else if (allCompleted) { | ||
setAllCompleted(false); | ||
} | ||
}, [allCompleted, completedTodos, todos.length]); |
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 can just be the variable
const isAllCompleted = completedTodos.length > 0 && completedTodos.length === todos.length
src/App.tsx
Outdated
const [error, setError] = useState<string>(''); | ||
const [allCompleted, setAllCompleted] = useState<boolean>(false); | ||
const [editedInputById, setEditedInputById] = useState<number>(-1); | ||
const [key, setKey] = useState<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.
we don't need a separate state for the key, feel free to ask for some help in the chat
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 do you think so?
src/App.tsx
Outdated
const [idsOfRecedingTodos, setIdsOfRecedingTodos] = useState<number[]>([]); | ||
const [tempTodo, setTempTodo] = useState<Todo | null>(null); | ||
const [idsOfTodosOnSelect, setIdsOfTodosOnSelect] = useState<number[]>([]); |
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.
I think idsOfRecedingTodos and idsOfTodosOnSelect can be united in one state
src/App.tsx
Outdated
function allSelected() { | ||
setFilter(Filter.all); | ||
} | ||
|
||
function activeSelected() { | ||
setFilter(Filter.active); | ||
} | ||
|
||
function completedSelected() { | ||
setFilter(Filter.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.
it's redundant to create three functions and pass them into Footer, just pass the setFilter function
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.
Awesome!
DEMO LINK