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

Fixed ReviewsList keys and links #812

Merged
merged 1 commit into from
Oct 25, 2023

Conversation

ARADDCC012
Copy link
Member

No description provided.

export default function ReviewItem({ review }: ReviewItemProps) {
const router = useRouter()

function handleListItemClick() {
Copy link
Member Author

Choose a reason for hiding this comment

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

This function has been changed, the rest of the file is the same as it was when the component was in ReviewsList.tsx

@@ -24,7 +22,7 @@ export default function ReviewsList({ isActive = true, kind = 'all' }: ReviewsLi
} else {
setFilteredReviews(reviews.filter((filteredReview) => filteredReview.kind === kind))
}
}, [reviews, setFilteredReviews, kind])
Copy link
Member Author

Choose a reason for hiding this comment

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

For some reason having the setState function in the dependency array was causing too many rerenders. Not sure why that would happen as it should be stable.

The React docs on hooks state the following: "React guarantees that setState function identity is stable and won’t change on re-renders. This is why it’s safe to omit from the useEffect or useCallback dependency list."

So I've removed it as it's unnecessary and was causing issues.

@@ -36,49 +34,12 @@ export default function ReviewsList({ isActive = true, kind = 'all' }: ReviewsLi
{filteredReviews.length === 0 && <EmptyBlob text='No reviews found' />}
<List>
{filteredReviews.map((review) => (
<ReviewItem key={review.semver} review={review} />
Copy link
Member Author

@ARADDCC012 ARADDCC012 Oct 25, 2023

Choose a reason for hiding this comment

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

review.semver isn't a unique key because:
a. Access request reviews don't have a semver
b. Releases can have two reviews with the same semver
c. Release for different models could have the same semver

@ARADDCC012 ARADDCC012 merged commit 9ea66cc into main Oct 25, 2023
@ARADDCC012 ARADDCC012 deleted the bugifx/reviews-always-link-to-releases-tab branch October 25, 2023 14:06
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