-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 #2709
base: master
Are you sure you want to change the base?
solution #2709
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 main functionality! 🎉 While there are a few minor improvements suggested, such as initializing todos
as an empty array and enhancing error handling, these do not critically impact the functionality. Keep up the good work and consider the feedback for future enhancements! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
|
||
export const App: React.FC = () => { | ||
const [isLoading, setIsLoading] = useState(true); | ||
const [isModalVisible, setIsModalVisible] = useState(false); | ||
const [todos, setTodos] = useState<Todo[] | null>(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.
Consider initializing todos
as an empty array []
instead of null
to avoid potential issues when passing it to the TodoList
component. This will make it easier to handle the list of todos without checking for null
.
import { getTodos } from '../../api'; | ||
|
||
type Props = { | ||
setTodos: React.Dispatch<React.SetStateAction<Todo[] | 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.
The setTodos
prop expects a state action for Todo[] | null
. However, it would be more consistent with the rest of the application to initialize todos
as an empty array instead of null
. This would simplify the logic and avoid potential null checks.
</tr> | ||
</thead> | ||
type Props = { | ||
todos: Todo[] | 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.
The todos
prop is typed as Todo[] | null
. It would be more consistent to initialize todos
as an empty array instead of null
, as this would simplify the logic and avoid potential null checks when mapping over the todos.
}, 1000); | ||
|
||
if (todo) { | ||
getUser(todo.userId).then(setUser); |
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.
Consider adding error handling for the getUser
API call to manage cases where the user data cannot be fetched. This will make the component more robust and user-friendly.
|
||
{' by '} | ||
|
||
<a href="mailto:[email protected]">Leanne Graham</a> | ||
<a href="mailto:[email protected]">{user ? user.name : null}</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.
The email address in the href
attribute is hardcoded. Consider dynamically generating the email address based on the user
data if available, e.g., href={user ?
mailto:${user.email} : '#'}
. This will ensure the email link is accurate and relevant to the displayed user.
DEMO LINK