Skip to content

fix(charts): Stabilize ChartComponent reference in EventsChart#120037

Open
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/chart-component-memo
Open

fix(charts): Stabilize ChartComponent reference in EventsChart#120037
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/chart-component-memo

Conversation

@sentry

@sentry sentry Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

This PR addresses a static-component-definitions violation flagged by the React Compiler in static/app/components/charts/eventsChart.tsx.

Problem:
The ChartComponent used in the Chart component was being derived via an inline function getChartComponent() called directly within the render body. This meant that ChartComponent received a new identity on every render, causing React to unmount and remount the component subtree unnecessarily, and preventing compiler optimizations.

Solution:
The getChartComponent() helper function has been removed. The logic to determine the correct chart component (e.g., BarChart, LineChart, AreaChart) is now encapsulated within a useMemo hook. This ensures that ChartComponent maintains a stable reference across renders, only re-evaluating when its dependencies (chartComponent, showDaily, timeseriesData.length, forceChartType, yAxis) change. This resolves the static-component-definitions issue and allows for proper React Compiler optimization.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Fixes CODING-CONVENTIONS-35D

Comment @sentry <feedback> on this PR to have Autofix iterate on the changes.

@sentry
sentry Bot requested a review from a team as a code owner July 19, 2026 19:56
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant