-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
fix(events-screenshot): Stabilize AttachmentComponent reference #120036
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import type {ReactEventHandler} from 'react'; | ||
| import {useState} from 'react'; | ||
| import {useMemo, useState} from 'react'; | ||
| import {css} from '@emotion/react'; | ||
| import styled from '@emotion/styled'; | ||
|
|
||
|
|
@@ -72,7 +72,11 @@ | |
| onDelete(screenshotAttachmentId); | ||
| } | ||
|
|
||
| const AttachmentComponent = getImageAttachmentRenderer(screenshot) ?? ImageViewer; | ||
| const AttachmentComponent = useMemo( | ||
| () => getImageAttachmentRenderer(screenshot) ?? ImageViewer, | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| [screenshot.mimetype] | ||
| ); | ||
| const downloadUrl = `/api/0/projects/${organization.slug}/${projectSlug}/events/${eventId}/attachments/${screenshot.id}/`; | ||
|
|
||
| return ( | ||
|
Comment on lines
+75
to
82
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The Suggested FixMove the Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
|
|
||
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.
Conditional useMemo breaks hooks
High Severity
The new
useMemoforAttachmentComponentruns only after theif (!hasRole) return nullguard, so renders without role skip that hook while renders with role call it. IfhasRolechanges on the same mount, React’s hook order no longer matches and the tree can crash.Reviewed by Cursor Bugbot for commit 61841ab. Configure here.