Skip to content

fix(attachments): Resolve static-component-definitions in screenshot viewers#120043

Open
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/static-component-definitions-screenshot-viewers
Open

fix(attachments): Resolve static-component-definitions in screenshot viewers#120043
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/static-component-definitions-screenshot-viewers

Conversation

@sentry

@sentry sentry Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

This PR addresses the static-component-definitions linting error (CODING-CONVENTIONS-366) found in static/app/components/events/eventTagsAndScreenshot/screenshot/modal.tsx and static/app/components/events/eventTagsAndScreenshot/screenshot/index.tsx.

Root Cause:
The issue stemmed from dynamically determining a React component type (AttachmentComponent) during the render cycle using getImageAttachmentRenderer(). This violates React's rule that component types used in JSX must be stable references at module scope, leading to unnecessary unmounting/remounting and blocking React Compiler optimizations.

Solution:
To resolve this, a new module-scoped component, ScreenshotAttachmentViewer, was introduced in static/app/components/events/attachmentViewers/previewAttachmentTypes.tsx. This component now encapsulates the logic for conditionally rendering either ImageViewer or VideoViewer based on the attachment's mimetype, using static JSX branches.

Changes Made:

  • static/app/components/events/attachmentViewers/previewAttachmentTypes.tsx: Added ScreenshotAttachmentViewer which takes ViewerProps and renders the appropriate viewer (VideoViewer for webm, ImageViewer otherwise) using static conditional logic.
  • static/app/components/events/eventTagsAndScreenshot/screenshot/modal.tsx: Replaced the dynamic AttachmentComponent variable and its usage with the new, stable ScreenshotAttachmentViewer component.
  • static/app/components/events/eventTagsAndScreenshot/screenshot/index.tsx: Applied the same fix, replacing the dynamic AttachmentComponent with ScreenshotAttachmentViewer.

This ensures that the component type remains stable across renders, satisfying the static-component-definitions rule and allowing for better React performance and 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-366

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:57
@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