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

final #1979

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

final #1979

wants to merge 2 commits into from

Conversation

ykrapivka
Copy link

No description provided.

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.

Your implementation is almost there! 🎉 However, there's a critical issue with the event listener in App.tsx that needs to be addressed. The removeEventListener method is not removing the listener correctly because a new function reference is being used. To fix this, define the event handler as a class method or property to ensure the same reference is used. Once this is resolved, your code will be in great shape! Keep up the good work! 😊

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review button in the Reviewers tab.

src/App.tsx Outdated
Comment on lines 18 to 21
componentWillUnmount() {
document.removeEventListener('keyup', (event: KeyboardEvent) => {
this.setState({ pressedKey: event.key });
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removeEventListener method is not removing the event listener correctly. You are passing a new function to removeEventListener, which does not match the original function added in componentDidMount. To fix this, you should define the event handler as a class method or a property and use the same reference in both addEventListener and removeEventListener.

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 your project! 🎉 While your code is mostly in good shape, there are a few critical issues that need attention:

  1. Event Listener Issue: In App.tsx, the removeEventListener method is not functioning correctly because a new function reference is being used. To resolve this, define the event handler as a class method or property to ensure the same reference is used for both adding and removing the event listener.

  2. Naming Convention: The method stateSet does not follow the naming convention specified in the checklist. Method names should start with a verb for clarity and consistency.

  3. Readability: The ternary operator in the render method should be formatted according to readability guidelines, with each operand on a separate line.

Despite these issues, your project meets all other requirements and constraints. The decision to approve is made to help you move forward with your learning journey. Please take the time to review the comments and improve your code. Addressing these critical issues will enhance the functionality and maintainability of your code. Keep up the great work and continue learning from these experiences! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

Comment on lines +23 to +25
document.removeEventListener('keyup', (event: KeyboardEvent) => {
this.stateSet(event);
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removeEventListener method is not removing the listener correctly because a new function reference is being used. You should define the event handler as a class method or property to ensure the same reference is used in both addEventListener and removeEventListener. This will fix the issue with the event listener not being removed properly.

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