-
Notifications
You must be signed in to change notification settings - Fork 15
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
Conversation
export default function ReviewItem({ review }: ReviewItemProps) { | ||
const router = useRouter() | ||
|
||
function handleListItemClick() { |
There was a problem hiding this comment.
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]) |
There was a problem hiding this comment.
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} /> |
There was a problem hiding this comment.
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
No description provided.