Skip to content

Solution#1779

Open
JPodgrodzki wants to merge 2 commits intomate-academy:masterfrom
JPodgrodzki:develop
Open

Solution#1779
JPodgrodzki wants to merge 2 commits intomate-academy:masterfrom
JPodgrodzki:develop

Conversation

@JPodgrodzki
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.

Review Summary

Hey there! 👋 The code implements the goods selector functionality well, but there are a couple of things we need to address. The main issue is the use of inline event handlers, as highlighted in the checklist. Creating separate methods for your onClick handlers will improve code maintainability and prevent unnecessary re-renders. I've provided an example in the comments. Also, remember that when using arrow functions as onClick handlers without arguments, you can directly pass the method instead of creating a new arrow function. Keep up the great work! 💪


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

Important

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

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

src/App.tsx Outdated
data-cy="ClearButton"
type="button"
className="delete ml-3"
onClick={() => setSelectedGood('')}

Choose a reason for hiding this comment

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

This is an inline event handler. According to the checklist item 2, it's better to define a separate method and pass it to the onClick prop.

<button 
  type="button"
  onClick={() => {}}
>
 Click me
</button>

GOOD EXAMPLE:

handleClick = () => {};

return (
  <button 
    type="button"
    onClick={handleClick}
  >
   Click me
</button>
)

src/App.tsx Outdated
data-cy="RemoveButton"
type="button"
className="button is-info"
onClick={() => setSelectedGood('')}

Choose a reason for hiding this comment

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

This is an inline event handler. According to the checklist item 2, it's better to define a separate method and pass it to the onClick prop.

<button 
  type="button"
  onClick={() => {}}
>
 Click me
</button>

GOOD EXAMPLE:

handleClick = () => {};

return (
  <button 
    type="button"
    onClick={handleClick}
  >
   Click me
</button>
)

src/App.tsx Outdated
data-cy="AddButton"
type="button"
className="button"
onClick={() => setSelectedGood(good)}

Choose a reason for hiding this comment

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

This is an inline event handler. According to the checklist item 2, it's better to define a separate method and pass it to the onClick prop.

<button 
  type="button"
  onClick={() => {}}
>
 Click me
</button>

GOOD EXAMPLE:

handleClick = () => {};

return (
  <button 
    type="button"
    onClick={handleClick}
  >
   Click me
</button>
)

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.

Review Summary

The code is well-structured and implements the goods selector functionality. There's a minor issue with the onClick handler in src/App.tsx where an arrow function is used inline: onClick={() => handleAddGood(good)}. According to the checklist, since handleAddGood already takes an argument, you should pass the method directly: onClick={handleAddGood}. I'm approving this PR to help you move forward, but please address this inline event handler issue in the future to avoid unnecessary re-renders and improve performance. Keep up the great work!


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

Footnotes

  1. Rate AI review example

data-cy="AddButton"
type="button"
className="button"
onClick={() => handleAddGood(good)}

Choose a reason for hiding this comment

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

According to the checklist, you should avoid inline event handlers to prevent creating a new arrow function after component re-rendering. Consider creating a separate method for this onClick handler.

Checklist item: 2. [CODE KNOWLEDGE] - Create separate methods instead of creating inline event handlers (if we do so - we don't create new arrow function after component re-rendering)

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