Skip to content
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

solution #2888

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

Yevhen-Filimonov
Copy link

Copy link

@BudnikOleksii BudnikOleksii left a comment

Choose a reason for hiding this comment

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

Good work 👍
Left comments to improve your solution

src/App.tsx Outdated
Comment on lines 26 to 27
setTitleError(false);
setUserError(false);

Choose a reason for hiding this comment

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

You don't need reset errors at first

src/App.tsx Outdated
setUserError(true);
}

if (title.trim() && userId !== 0) {

Choose a reason for hiding this comment

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

You do title.trim() and userId !== 0 comparasion twice, create variables

src/App.tsx Outdated

// import usersFromServer from './api/users';
// import todosFromServer from './api/todos';
const findUserId = (userId: number) =>

Choose a reason for hiding this comment

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

Suggested change
const findUserId = (userId: number) =>
const findUserById = (userId: number) =>

As I see you are looking for user in this function not for id

src/App.tsx Outdated
userId,
};

setTodos([...todos, newTodo]);

Choose a reason for hiding this comment

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

When you set state depending on the previous one use functional setState

src/App.tsx Outdated
Comment on lines 47 to 48
setTitle('');
setUserId(0);

Choose a reason for hiding this comment

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

Create a function for resetting

src/App.tsx Outdated
Comment on lines 20 to 21
const [titleError, setTitleError] = useState<boolean>(false);
const [userError, setUserError] = useState<boolean>(false);

Choose a reason for hiding this comment

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

Boolean variables should start from is or has

src/App.tsx Outdated
Comment on lines 65 to 68
onChange={(e: ChangeEvent<HTMLInputElement>) => {
setTitle(e.target.value);
setTitleError(false);
}}

Choose a reason for hiding this comment

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

Create functions instead of passing anonim function to onChange events

return (
<article
data-id={todo.id}
className={`TodoInfo ${todo.completed ? 'TodoInfo--completed' : ''}`}

Choose a reason for hiding this comment

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

To set classes conditionally use classnames or clsx library

Copy link

@StasSokolov1 StasSokolov1 left a comment

Choose a reason for hiding this comment

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

Looks much more better now, I'm approving it🔥

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.

4 participants