Skip to content

feat(react): loading todos#2416

Open
xapg6acc wants to merge 3 commits into
mate-academy:masterfrom
xapg6acc:master
Open

feat(react): loading todos#2416
xapg6acc wants to merge 3 commits into
mate-academy:masterfrom
xapg6acc:master

Conversation

@xapg6acc

Copy link
Copy Markdown

@etojeDenys etojeDenys left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good job, to improve:

demo looks broken

Image

Comment thread src/App.tsx Outdated
getTodos()
.then(setTodos)
.catch(() => {
setErrorMessage('Unable to load todos');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create an enum for errors as well

Comment thread src/App.tsx Outdated
export const App: React.FC = () => {
const [todos, setTodos] = useState<Todo[]>([]);
const [filter, setFilter] = useState<FilterStatus>(FilterStatus.ALL);
const [errorMessage, setErrorMessage] = useState<string>('');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't have to specify simple types

Suggested change
const [errorMessage, setErrorMessage] = useState<string>('');
const [errorMessage, setErrorMessage] = useState('');

Comment thread src/components/Filter.tsx Outdated
Comment on lines +14 to +45
<a
href="#/"
className={classNames('filter__link', {
selected: filter === FilterStatus.ALL,
})}
data-cy="FilterLinkAll"
onClick={() => onFilterChange(FilterStatus.ALL)}
>
All
</a>

<a
href="#/active"
className={classNames('filter__link', {
selected: filter === FilterStatus.ACTIVE,
})}
data-cy="FilterLinkActive"
onClick={() => onFilterChange(FilterStatus.ACTIVE)}
>
Active
</a>

<a
href="#/completed"
className={classNames('filter__link', {
selected: filter === FilterStatus.COMPLETED,
})}
data-cy="FilterLinkCompleted"
onClick={() => onFilterChange(FilterStatus.COMPLETED)}
>
Completed
</a>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can create an array with the required parameters and then map through it to create links and avoid code repetition

@xapg6acc xapg6acc requested a review from etojeDenys July 1, 2026 10:51

@brespect brespect left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants