From 6e2973aa2d3dc9466f2cc9b352e0eb2b260bf463 Mon Sep 17 00:00:00 2001 From: Echo Date: Mon, 20 Oct 2025 16:52:27 +0200 Subject: [PATCH] Emoji: Fix unneeded re-renders when StatusContent changes (#36532) --- app/javascript/mastodon/components/status_content.jsx | 4 ++-- .../components/embedded_status_content.tsx | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/javascript/mastodon/components/status_content.jsx b/app/javascript/mastodon/components/status_content.jsx index 14779ce3a..d2820ef0a 100644 --- a/app/javascript/mastodon/components/status_content.jsx +++ b/app/javascript/mastodon/components/status_content.jsx @@ -269,7 +269,7 @@ class StatusContent extends PureComponent { lang={language} htmlString={content} extraEmojis={status.get('emojis')} - onElement={this.handleElement.bind(this)} + onElement={this.handleElement} /> {poll} @@ -287,7 +287,7 @@ class StatusContent extends PureComponent { lang={language} htmlString={content} extraEmojis={status.get('emojis')} - onElement={this.handleElement.bind(this)} + onElement={this.handleElement} /> {poll} diff --git a/app/javascript/mastodon/features/notifications_v2/components/embedded_status_content.tsx b/app/javascript/mastodon/features/notifications_v2/components/embedded_status_content.tsx index b7dc998a4..1d1b684b8 100644 --- a/app/javascript/mastodon/features/notifications_v2/components/embedded_status_content.tsx +++ b/app/javascript/mastodon/features/notifications_v2/components/embedded_status_content.tsx @@ -46,11 +46,15 @@ export const EmbeddedStatusContent: React.FC<{ () => (status.get('mentions') as List).toJS(), [status], ); - const htmlHandlers = useElementHandledLink({ - hashtagAccountId: status.get('account') as string | undefined, - hrefToMention(href) { + const hrefToMention = useCallback( + (href: string) => { return mentions.find((item) => item.url === href); }, + [mentions], + ); + const htmlHandlers = useElementHandledLink({ + hashtagAccountId: status.get('account') as string | undefined, + hrefToMention, }); const handleContentRef = useCallback(