-
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
add rask solution #1101
base: master
Are you sure you want to change the base?
add rask solution #1101
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.
Good job 👍
Let's improve your code
src/api/localStorage.ts
Outdated
import { useState } from 'react'; | ||
import { Todo } from '../types/Todo'; | ||
|
||
export function useLocalStorage(key: string, initialState: 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.
It is important to follow the same way of creating functions everywhere
export function useLocalStorage(key: string, initialState: Todo[]) { | |
export const useLocalStorage = (key: string, initialState: Todo[]) => { |
src/components/Footer.tsx
Outdated
<nav className="filter" data-cy="Filter"> | ||
<a | ||
href="#/" | ||
className={classNames('filter__link', { selected: filter === 'All' })} |
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 enum for 'All', 'Active', 'Completed' and use it everywhere
src/components/Footer.tsx
Outdated
<a | ||
href="#/" | ||
className={classNames('filter__link', { selected: filter === 'All' })} | ||
data-cy="FilterLinkAll" | ||
onClick={() => { setFilter('All') }} | ||
> | ||
All | ||
</a> | ||
|
||
<a | ||
href="#/active" | ||
className={classNames('filter__link', { | ||
selected: filter === 'Active', | ||
})} | ||
data-cy="FilterLinkActive" | ||
onClick={() => { | ||
setFilter('Active'); | ||
}} | ||
> | ||
Active | ||
</a> | ||
|
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 Object.values(your created enum)
and render these options with map()
method
src/components/TodoInfo.tsx
Outdated
return ( | ||
<div | ||
data-cy="Todo" | ||
className={classNames('todo', { completed: 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.
className={classNames('todo', { completed: todo.completed })} | |
className={classNames('todo', { completed })} |
|
||
export const App: React.FC = () => { | ||
const { todos } = useLocalStorageContext(); | ||
|
||
localStorage.removeItem('todoss'); |
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.
localStorage.removeItem('todoss'); |
https://shymdima.github.io/react_todo-app/