-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
react_dynamic-list-of-todos_v-01 #1952
base: master
Are you sure you want to change the base?
Conversation
src/App.tsx
Outdated
const [query, setQuery] = useState<string>(''); | ||
const [status, setStatus] = useState<string>('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.
it's redundant to specify the primitive types
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! Some small fixes:
src/App.tsx
Outdated
|
||
export const App: React.FC = () => { | ||
const [todos, setTodos] = useState<Todo[]>([]); | ||
const [loading, setLoading] = useState(false); |
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 [loading, setLoading] = useState(false); | |
const [isLoading, setIsLoading] = useState(false); |
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/App.tsx
Outdated
const [loading, setLoading] = useState(false); | ||
const [selectedTodo, setSelectedTodo] = useState<Todo | null>(null); | ||
const [query, setQuery] = useState(''); | ||
const [status, setStatus] = useState('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.
use enum for filter values
src/App.tsx
Outdated
(status === 'all' || (status === 'completed' && todo.completed) || (status === 'active' && !todo.completed)) | ||
&& todo.title.toLowerCase().includes(query.toLowerCase()) |
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.
could you simplify this expression
src/components/TodoList/TodoList.tsx
Outdated
<tr | ||
data-cy="todo" | ||
key={todo.id} | ||
className={cn({ | ||
'has-background-info-light': selectedTodo === todo, | ||
})} | ||
> | ||
<td className="is-vcentered">{todo.id}</td> | ||
<td className="is-vcentered"> | ||
{todo.completed && ( | ||
<span className="icon" data-cy="iconCompleted"> | ||
<i className="fas fa-check" /> | ||
</span> | ||
)} | ||
</td> | ||
<td className="is-vcentered is-expanded"> | ||
<p | ||
className={cn({ | ||
'has-text-success': todo.completed, | ||
'has-text-danger': !todo.completed, | ||
})} | ||
> | ||
{todo.title} | ||
</p> | ||
</td> | ||
<td className="has-text-right is-vcentered"> | ||
<button | ||
data-cy="selectButton" | ||
className="button" | ||
type="button" | ||
onClick={() => onSelect(todo)} | ||
> | ||
<span className="icon"> | ||
<i | ||
className={cn('far', { | ||
'fa-eye-slash': selectedTodo === todo, | ||
'fa-eye': selectedTodo !== todo, | ||
})} | ||
/> | ||
</span> |
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.
let's move this logic to the TodoItem component
onClose = () => { }, | ||
selectedTodo, | ||
}) => { | ||
const [loading, setLoading] = useState(false); |
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 [loading, setLoading] = useState(false); | |
const [isLoading, setIsLoading] = useState(false); |
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.
Looks good
DEMO LINK