Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions src/panel/components/IssueCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react';
import React, { useState } from 'react';
import type { Issue } from '@/types';

interface IssueCardProps {
Expand All @@ -12,6 +12,7 @@ const SEVERITY_CONFIG = {
};

const ISSUE_INFO: Record<string, { title: string; why: string; learnUrl?: string }> = {

MISSING_KEY: {
title: 'Missing Key in List',
why: 'Keys help React identify which items have changed, are added, or removed.',
Expand Down Expand Up @@ -54,13 +55,13 @@ const ISSUE_INFO: Record<string, { title: string; why: string; learnUrl?: string
},
};

export function IssueCard({ issue }: IssueCardProps) {
const [expanded, setExpanded] = useState(false);
export const IssueCard = React.memo(function IssueCard({ issue }: IssueCardProps) {

const [expanded, setExpanded] = useState(false);
const severity = SEVERITY_CONFIG[issue.severity];
const info = ISSUE_INFO[issue.type] || { title: issue.type, why: '' };
const location = issue.location;

const renderCountMatch = issue.message.match(/Rendered (\d+) times/);
const renderCount = renderCountMatch ? parseInt(renderCountMatch[1], 10) : null;

Expand All @@ -74,12 +75,12 @@ export function IssueCard({ issue }: IssueCardProps) {
<div className="issue-info">
<div className="issue-title-row">
<h4 className="issue-title">{info.title}</h4>
<span
className="severity-badge"
style={{
backgroundColor: severity.bgColor,
<span
className="severity-badge"
style={{
backgroundColor: severity.bgColor,
color: severity.color,
border: `1px solid ${severity.color}`
border: `1px solid ${severity.color}`,
}}
>
{severity.label}
Expand Down Expand Up @@ -151,7 +152,7 @@ export function IssueCard({ issue }: IssueCardProps) {
</span>
</div>
</div>

<div className="closure-details">
<div className="closure-row">
<span className="closure-label">Function:</span>
Expand Down Expand Up @@ -207,7 +208,7 @@ export function IssueCard({ issue }: IssueCardProps) {
</div>
)}

<div className="issue-actions">
<div className="issue-actions">
{info.learnUrl && (
<a
href={info.learnUrl}
Expand All @@ -223,4 +224,4 @@ export function IssueCard({ issue }: IssueCardProps) {
)}
</div>
);
}
});