-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
have some problems #1961
have some problems #1961
Conversation
src/App.tsx
Outdated
user: getUserById(todo.userId) | ||
|| { | ||
id: 0, name: '', username: '', email: '', | ||
}, | ||
})) as TodoWithUser[]; |
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 let's just return null
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 [posts, setPosts] = useState<TodoWithUser[]>(todos); | ||
|
||
const addPost = (post: TodoWithUser) => { |
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
return; | ||
} | ||
|
||
const newPost: TodoWithUser = ({ |
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/components/TodoInfo/TodoInfo.tsx
Outdated
const { title, completed, user } = todo; | ||
|
||
return ( | ||
<article className={`TodoInfo ${completed ? 'TodoInfo--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.
let's use classNames package for such cases
src/components/TodoInfo/TodoInfo.tsx
Outdated
<article className={`TodoInfo ${completed ? 'TodoInfo--completed' : ''}`}> | ||
<h2 className="TodoInfo__title">{title}</h2> | ||
|
||
<UserInfo user={user} /> |
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.
user can be null let's handle this case here
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.
Did you forget to push changes?) Previous comments aren’t fixed
Also pls add demo link
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.
Not all previous comments were fixed. Check them below
src/App.tsx
Outdated
user: getUserById(todo.userId) | ||
|| { | ||
id: 0, name: '', username: '', email: '', | ||
}, | ||
})) as TodoWithUser[]; |
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
user: getUserById(userId) || { | ||
id: 0, | ||
name: '', | ||
username: '', | ||
email: '', | ||
}, |
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.
user: getUserById(userId) || { | |
id: 0, | |
name: '', | |
username: '', | |
email: '', | |
}, | |
user: getUserById(userId), |
src/components/TodoInfo/TodoInfo.tsx
Outdated
const { title, completed, user } = todo; | ||
|
||
return ( | ||
<article className={`TodoInfo ${completed ? 'TodoInfo--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.
src/components/TodoInfo/TodoInfo.tsx
Outdated
<article className={`TodoInfo ${completed ? 'TodoInfo--completed' : ''}`}> | ||
<h2 className="TodoInfo__title">{title}</h2> | ||
|
||
{user !== undefined && <UserInfo user={user} />} |
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.
{user !== undefined && <UserInfo user={user} />} | |
{user && <UserInfo user={user} />} |
src/types/types.ts
Outdated
email: string; | ||
}; | ||
|
||
export type TodoWithUser = Todos & { user?: Users }; |
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.
export type TodoWithUser = Todos & { user?: Users }; | |
export type TodoWithUser = Todos & { user: Users | null }; |
No description provided.