Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Great work on this task! Your application is fully functional and meets all the core requirements. The logic for selecting, displaying, and clearing goods works correctly.
I have one important recommendation for improvement regarding your event handlers. In src/App.tsx, using an inline arrow function for the onClick event creates a new function on every render, which can impact performance. This goes against a best practice noted in the checklist [CHECKLIST ITEM #2]. A better approach is to create a single event handler method that determines which item was clicked, for example, by using a data- attribute.
Since the functionality is correct, your solution is approved. Keep this performance best practice in mind for future projects!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
src/App.tsx
Outdated
| data-cy="AddButton" | ||
| type="button" | ||
| className="button" | ||
| onClick={() => this.selectGood(good)} |
There was a problem hiding this comment.
This violates checklist item #2: 'Create separate methods instead of creating inline event handlers'. Using an inline arrow function for onClick creates a new function on every render, which can impact performance.
Consider creating a single event handler method on the class that can determine which 'good' was clicked, for example, by using a data- attribute on the button.
DEMO LINK