-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
base: master
Are you sure you want to change the base?
final #1979
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.
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
componentWillUnmount() { | ||
document.removeEventListener('keyup', (event: KeyboardEvent) => { | ||
this.setState({ pressedKey: event.key }); | ||
}); |
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 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
.
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 your project! 🎉 While your code is mostly in good shape, there are a few critical issues that need attention:
-
Event Listener Issue: In
App.tsx
, theremoveEventListener
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. -
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. -
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! ✨
document.removeEventListener('keyup', (event: KeyboardEvent) => { | ||
this.stateSet(event); | ||
}); |
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 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.
No description provided.