-
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
Develop #2925
base: master
Are you sure you want to change the base?
Develop #2925
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 on implementing the task requirements! 🎉 While there are a few minor improvements suggested, such as handling undefined users and improving variable naming, these do not critically impact the functionality. Keep up the good work and consider these suggestions for future enhancements! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
src/App.tsx
Outdated
|
||
export const App = () => { | ||
const [todos, setTodos] = useState([...initialTodos]); |
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.
Using useState([...initialTodos])
is unnecessary because initialTodos
is already a new array. You can simply use useState(initialTodos)
.
import { TodoList } from './components/TodoList'; | ||
|
||
function findUserById(userId: number): User | undefined { | ||
return usersFromServer.find(user => user.id === userId); |
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.
The findUserById
function returns undefined
if no user is found. Ensure that this case is handled appropriately in your application, especially when rendering components that depend on the user object.
src/components/Form/Form.tsx
Outdated
Choose a user | ||
</option> | ||
|
||
{users.map(u => ( |
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.
Avoid using one-letter variable names like u
. Instead, use more descriptive names such as user
to improve code readability. This aligns with the checklist item: "Don't use one-letter variable naming."
src/components/Form/Form.tsx
Outdated
}; | ||
|
||
return ( | ||
<form action="/api/todos" method="POST" onSubmit={handleSubmit}> |
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.
The action
attribute in the form tag might not be necessary if you are handling form submission entirely with JavaScript. Consider removing it if it's not needed.
> | ||
<h2 className="TodoInfo__title">{todo.title}</h2> | ||
|
||
<UserInfo user={todo.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.
Ensure that the user
property passed to UserInfo
is not null
or undefined
before rendering. This aligns with the checklist item: "Don't render the component if the property that you pass to the component has null
or undefined
value." Consider adding a conditional check before rendering UserInfo
.
DEMO LINK