diff --git a/.changeset/fix-conditional.md b/.changeset/fix-conditional.md new file mode 100644 index 000000000..61ab9200c --- /dev/null +++ b/.changeset/fix-conditional.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Fix conditional memo in reply renderer leading to crashes. diff --git a/src/app/components/message/Reply.tsx b/src/app/components/message/Reply.tsx index b5032f4df..5ae0ebdec 100644 --- a/src/app/components/message/Reply.tsx +++ b/src/app/components/message/Reply.tsx @@ -132,6 +132,22 @@ export const Reply = as<'div', ReplyProps>( let bodyJSX: ReactNode = fallbackBody; let image: IconSrc | undefined; + const replyLinkifyOpts = useMemo( + () => ({ + ...LINKIFY_OPTS, + render: factoryRenderLinkifyWithMention((href) => + renderMatrixMention( + mx, + room.roomId, + href, + makeMentionCustomProps(mentionClickHandler), + nicknames + ) + ), + }), + [mx, room.roomId, mentionClickHandler, nicknames] + ); + if (format === 'org.matrix.custom.html' && formattedBody) { const strippedHtml = trimReplyFromFormattedBody(formattedBody) .replaceAll(//gi, ' ') @@ -140,21 +156,6 @@ export const Reply = as<'div', ReplyProps>( .replaceAll(/<\/li>\s*]*>/gi, ' ') .replaceAll(/<\/?(ul|ol|li|blockquote|h[1-6]|pre|div)[^>]*>/gi, '') .replaceAll(/(?:\r\n|\r|\n)/g, ' '); - const replyLinkifyOpts = useMemo( - () => ({ - ...LINKIFY_OPTS, - render: factoryRenderLinkifyWithMention((href) => - renderMatrixMention( - mx, - room.roomId, - href, - makeMentionCustomProps(mentionClickHandler), - nicknames - ) - ), - }), - [mx, room.roomId, mentionClickHandler, nicknames] - ); const parserOpts = getReactCustomHtmlParser(mx, room.roomId, { linkifyOpts: replyLinkifyOpts, useAuthentication,