-
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
add solution #2121
base: master
Are you sure you want to change the base?
add solution #2121
Conversation
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.
Great job!
export const UserInfo: React.FC<Props> = ({ user }) => { | ||
return ( | ||
<a className="UserInfo" href={`mailto:${user?.email}`}> | ||
{user?.name} | ||
</a> | ||
); | ||
}; |
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.
[REACT KNOWLEDGE] - Don't render the component if the property that you pass to the component has null
or undefined
value.
you should check if user is not undefined
before render
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! I'm approving it, but please pay attention to the comments)
|
||
export const App = () => { | ||
const [currentData, setCurrentData] = useState<TodoWithUser[]>(dataList); | ||
const [title, setTitle] = useState(''); | ||
const [currennUserId, setCurrentUserId] = useState(0); |
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 [currennUserId, setCurrentUserId] = useState(0); | |
const [currentUserId, setCurrentUserId] = useState(0); |
return usersFromServer.find((user) => user.id === userId) || null; | ||
} | ||
|
||
const dataList = todosFromServer.map((todo) => { |
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 dataList = todosFromServer.map((todo) => { | |
const todosWithUsers = todosFromServer.map((todo) => { |
Would be great to use descriptive meaningful names
setSelectValid(false); | ||
} | ||
|
||
const handlerSubmit = (event: React.ChangeEvent<HTMLFormElement>) => { |
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 handlerSubmit = (event: React.ChangeEvent<HTMLFormElement>) => { | |
const handleSubmit = (event: React.ChangeEvent<HTMLFormElement>) => { |
DEMO LINK