️(frontend) memoize the KeyboardShortcutHint component

The KeyboardShortcutHint component only renders a string and has no
reason to re-render on unrelated updates. Memoize it to skip those
re-renders.
This commit is contained in:
lebaudantoine
2026-07-13 20:33:37 +02:00
parent 0079aa8176
commit 7cc16303d9
2 changed files with 12 additions and 10 deletions
@@ -1,4 +1,4 @@
import React, { ReactNode } from 'react'
import React from 'react'
import { styled } from '@/styled-system/jsx'
const Hint = styled('div', {
@@ -25,15 +25,17 @@ const Hint = styled('div', {
})
export interface KeyboardShortcutHintProps {
children: ReactNode
hint?: string
}
/**
* Small reusable bubble used to display and announce keyboard shortcuts,
* typically when an element receives keyboard focus.
*/
export const KeyboardShortcutHint: React.FC<KeyboardShortcutHintProps> = ({
children,
}) => {
return <Hint>{children}</Hint>
}
export const KeyboardShortcutHint = React.memo(
({ hint }: KeyboardShortcutHintProps) => {
return <Hint>{hint}</Hint>
}
)
KeyboardShortcutHint.displayName = 'KeyboardShortcutHint'
@@ -241,13 +241,13 @@ export const ParticipantTile: (
)}
</ParticipantContextIfNeeded>
</TrackRefContextIfNeeded>
<KeyboardShortcutHint>
{t('toolbarHint', {
<KeyboardShortcutHint
hint={t('toolbarHint', {
shortcut: formatShortcutLabel(
getShortcutDescriptorById('open-shortcuts')?.shortcut
),
})}
</KeyboardShortcutHint>
/>
</div>
)
})