complete part 1 of todo app#2421
Open
Roma-Yamshchikov wants to merge 2 commits into
Open
Conversation
etojeDenys
suggested changes
Jul 4, 2026
etojeDenys
left a comment
There was a problem hiding this comment.
almost done
- split the app into several components
| const [title, setTitle] = useState(''); | ||
| const [todos, setTodos] = useState<Todo[]>([]); | ||
| const [error, setError] = useState<string | null>(null); | ||
| const [filter, setFilter] = useState('all'); |
There was a problem hiding this comment.
create an enum for the filter parameters
| setError(null); | ||
| getTodos() | ||
| .then(setTodos) | ||
| .catch(() => setError('Unable to load todos')); |
Comment on lines
+138
to
+158
| <a | ||
| href="#/" | ||
| className={classNames('filter__link', { | ||
| selected: filter === 'all', | ||
| })} | ||
| data-cy="FilterLinkAll" | ||
| onClick={() => setFilter('all')} | ||
| > | ||
| All | ||
| </a> | ||
|
|
||
| {/* 'is-active' class puts this modal on top of the todo */} | ||
| <div data-cy="TodoLoader" className="modal overlay is-active"> | ||
| <div className="modal-background has-background-white-ter" /> | ||
| <div className="loader" /> | ||
| </div> | ||
| </div> | ||
| </section> | ||
|
|
||
| {/* Hide the footer if there are no todos */} | ||
| <footer className="todoapp__footer" data-cy="Footer"> | ||
| <span className="todo-count" data-cy="TodosCounter"> | ||
| 3 items left | ||
| </span> | ||
|
|
||
| {/* Active link should have the 'selected' class */} | ||
| <nav className="filter" data-cy="Filter"> | ||
| <a | ||
| href="#/" | ||
| className="filter__link selected" | ||
| data-cy="FilterLinkAll" | ||
| > | ||
| 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.
you can create an array with the required parameters and then map through it to create links and avoid code repetition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DEMO LINK