Skip to content

Task solution#1777

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

Task solution#1777
MateuszCieplak wants to merge 2 commits intomate-academy:masterfrom
MateuszCieplak:develop

Conversation

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

Thank you for your hard work on this project! 😊 There are a few critical issues that need to be addressed before we can approve the pull request. The misspelling of the method name handleClik should be corrected to handleClick to maintain consistency and readability. Additionally, using inline event handlers can lead to performance issues, so it's best to refactor them into separate methods. Lastly, ensure that each list item has a unique key prop to meet React's requirements for list rendering. Once these changes are made, your code will be in great shape! Keep up the great 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
{/* eslint-disable-next-line jsx-a11y/control-has-associated-label */}
<button data-cy="ClearButton" type="button" className="delete ml-3" />
</h1>
handleClik = (good: string) => {

Choose a reason for hiding this comment

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

There is a typo in the method name handleClik. It should be handleClick to maintain consistency and readability.

src/App.tsx Outdated
type="button"
className="button"
onClick={() => {
this.handleClik(good);

Choose a reason for hiding this comment

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

Ensure that the method name handleClik is corrected to handleClick here as well.

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 addressing most of the issues from the previous review! 🎉 Your code is well on its way to meeting all the requirements. Here are some points to consider for further improvement:

  • Unique Key Prop: Ensure that each list item in the newTableGoods array has a unique key prop. This is crucial for React's list rendering efficiency. You might use the good value or its index as the key.

  • Inline Event Handlers: Although you've made progress, there's still an inline event handler in the onClick attribute of the AddButton. Refactoring this into a separate method will enhance code readability and maintainability.

Your solution meets the task requirements, handling the selection and clearing of goods effectively, and managing button visibility based on the selection state. Keep up the good work, and make sure to address the highlighted issues in future iterations to enhance your React skills. Remember, learning from these experiences will make you a better developer. 🚀

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

Comment on lines +43 to +81
const newTableGoods = goods.map(good => {
return good === selectedGood ? (
<tr data-cy="Good" className="has-background-success-light">
<td>
<button
data-cy="RemoveButton"
type="button"
className="button is-info"
onClick={this.clearClick}
>
-
</button>
</td>

<td data-cy="GoodTitle" className="is-vcentered">
Jam
{good}
</td>
</tr>

) : (
<tr data-cy="Good">
<td>
<button data-cy="AddButton" type="button" className="button">
<button
data-cy="AddButton"
type="button"
className="button"
onClick={() => {
this.handleClick(good);
}}
>
+
</button>
</td>

<td data-cy="GoodTitle" className="is-vcentered">
Garlic
{good}
</td>
</tr>
</tbody>
</table>
</main>
);
);
});

Choose a reason for hiding this comment

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

Each element in the newTableGoods array should have a unique key prop. This is important for React to efficiently update and render list items. Consider using the good value or its index in the array as the key.

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