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

test_1 #1977

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

test_1 #1977

wants to merge 2 commits into from

Conversation

igols
Copy link

@igols igols commented Feb 25, 2025

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.

Thank you for your hard work on this pull request! 😊 There are a few critical issues that need to be addressed before we can approve it.

  1. Typing Issues: The React.Component generic type is incorrectly used, which may lead to runtime errors. It should be React.Component<{}, State> since the component does not take any props. Additionally, the Props interface is being used to define the state, which is misleading. It would be clearer to rename Props to State.

  2. Method Naming: The method handle should start with a verb to clearly indicate its action. This aligns with best practices for method naming.

  3. Event Listener Management: The code does not include the removal of the event listener in componentWillUnmount. It's important to use removeEventListener to clean up and prevent potential memory leaks.

Please address these issues to ensure the code meets the task requirements and functions correctly. Once these changes are made, we can proceed with the approval. Keep up the great work, and don't hesitate to reach out if you have any questions! 🚀

✨ 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
message: string;
}

export class App extends React.Component<{}, Props> {

Choose a reason for hiding this comment

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

The React.Component generic type is used incorrectly. The first type parameter should be the type of the component's props, and the second should be the type of the component's state. Since this component does not take any props, the correct usage should be React.Component<{}, Props>.

src/App.tsx Outdated
Comment on lines 9 to 11
state: Props = {
message: 'Nothing was pressed yet',
};

Choose a reason for hiding this comment

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

The Props interface is being used to define the state, which is misleading. It's better to rename Props to something like State to accurately reflect its purpose.

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 code has been reviewed and approved! 🎉

Review Summary:

Great job on updating the code to address previous issues! The Props interface has been correctly renamed to State, and the event listener is now being removed in componentWillUnmount, which is a crucial improvement. The React.Component generic type is also correctly used with an empty props object.

However, there are still a few areas that need attention. The method handleButton should start with a verb to better reflect its action. Consider renaming it to something like handleKeyUp or onKeyUp to align with best practices for method naming.

Overall, your solution meets the task requirements and constraints. The App component is correctly implemented as a class component with a state, and the event handling is properly managed to prevent potential memory leaks. The message updates as expected when a key is pressed.

Keep up the great work, and make sure to review the comments to improve your code further. Addressing these issues will help you enhance your coding skills and avoid similar problems in the future. Keep learning and growing! 🚀

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

message: 'Nothing was pressed yet',
};

handleButton = (event: KeyboardEvent) => {

Choose a reason for hiding this comment

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

The method handleButton should start with a verb to clearly indicate its action. Consider renaming it to something like handleKeyUp or onKeyUp to align with best practices for method naming.

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