-
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
Develop #1021
base: master
Are you sure you want to change the base?
Develop #1021
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!
src/App.tsx
Outdated
Completed | ||
</a> | ||
</nav> | ||
<TodoList /> |
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.
Will we render this component of todos length equal 0?
src/Store.tsx
Outdated
type State = { | ||
todos: Todo[]; | ||
query: string; | ||
filter: SelectedFilter; | ||
editingTodoId: number | null; | ||
currentTitle: 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.
Consider creating .ts
file and move this file to this file
src/Store.tsx
Outdated
type Action = | ||
| { type: 'toogleAllChecked' } | ||
| { type: 'addTodo'; payload: Todo } | ||
| { type: 'setQuery'; payload: string } | ||
| { type: 'deleteTodo'; payload: number } | ||
| { type: 'massDelete'; payload: number[] } | ||
| { type: 'changeCheckbox'; payload: number } | ||
| { type: 'updateTodo'; payload: Todo } | ||
| { type: 'setCurrentTitle'; payload: string } | ||
| { type: 'setEditingTodoId'; payload: number | null } | ||
| { type: 'setFilter'; payload: SelectedFilter }; |
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.
Same
src/components/TodoItem.tsx
Outdated
import { Todo } from '../types/Todo'; | ||
import { EditForm } from './EditForm'; | ||
import { useGlobalDispatch, useGlobalState } from '../Store'; | ||
// import { deleteFromLocalStorage } from '../utils/LocaleStorage'; |
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 redundant comment
src/components/TodoItem.tsx
Outdated
const dispatch = useGlobalDispatch(); | ||
|
||
const handleDeleteTodo = (index: number) => { | ||
// deleteFromLocalStorage(id); |
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.
same
src/utils/LocaleStorage.ts
Outdated
export const loadFromLocalStorage = (): Todo[] => { | ||
const todos = localStorage.getItem('todos'); | ||
|
||
return todos ? JSON.parse(todos) : []; | ||
}; | ||
|
||
export const deleteFromLocalStorage = (id: number) => { | ||
let items = loadFromLocalStorage(); | ||
|
||
items = items.filter((item: Todo) => item.id !== id); | ||
|
||
localStorage.setItem('todos', JSON.stringify(items)); | ||
}; |
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.
Consider creating useLocalStorageHook
and replace this function with 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.
good job
DEMO LINK