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 #2709

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

solution #2709

wants to merge 1 commit into from

Conversation

YevhenRDoIT
Copy link

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a 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);

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>>;

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;

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);

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>

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.

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.

2 participants