Skip to content

Commit 886acde

Browse files
authored
Merge pull request Expensify#66239 from callstack-internal/perf/improve-MentionUserRenderer
perf: improve MentionUserRenderer performance
2 parents e6b8cb9 + 78759b5 commit 886acde

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona
3737
let accountID: number;
3838
let mentionDisplayText: string;
3939
let navigationRoute: Route;
40-
41-
const tnodeClone = cloneDeep(tnode);
40+
let tnodeClone: typeof tnode | undefined;
4241

4342
if (!isEmpty(htmlAttribAccountID) && personalDetails?.[htmlAttribAccountID]) {
4443
const user = personalDetails[htmlAttribAccountID];
4544
accountID = parseInt(htmlAttribAccountID, 10);
4645
mentionDisplayText = formatPhoneNumber(user?.login ?? '') || getDisplayNameOrDefault(user);
4746
mentionDisplayText = getShortMentionIfFound(mentionDisplayText, htmlAttributeAccountID, currentUserPersonalDetails, user?.login ?? '') ?? '';
4847
navigationRoute = ROUTES.PROFILE.getRoute(accountID, Navigation.getReportRHPActiveRoute());
49-
} else if ('data' in tnodeClone && !isEmptyObject(tnodeClone.data)) {
48+
} else if ('data' in tnode && !isEmptyObject(tnode.data)) {
49+
tnodeClone = cloneDeep(tnode);
5050
// We need to remove the LTR unicode and leading @ from data as it is not part of the login
5151
mentionDisplayText = tnodeClone.data.replace(CONST.UNICODE.LTR, '').slice(1);
5252
// We need to replace tnode.data here because we will pass it to TNodeChildrenRenderer below
@@ -106,7 +106,7 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona
106106
testID="mention-user"
107107
href={`/${navigationRoute}`}
108108
>
109-
{htmlAttribAccountID ? `@${mentionDisplayText}` : <TNodeChildrenRenderer tnode={tnodeClone} />}
109+
{htmlAttribAccountID ? `@${mentionDisplayText}` : <TNodeChildrenRenderer tnode={tnodeClone ?? tnode} />}
110110
</Text>
111111
</UserDetailsTooltip>
112112
</Text>

0 commit comments

Comments
 (0)