mirror of
https://github.com/suitenumerique/meet.git
synced 2026-08-26 02:06:53 +00:00
⚡️(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:
committed by
aleb_the_flash
parent
aba5fca655
commit
bf6351e838
@@ -1,4 +1,4 @@
|
|||||||
import React, { ReactNode } from 'react'
|
import React from 'react'
|
||||||
import { styled } from '@/styled-system/jsx'
|
import { styled } from '@/styled-system/jsx'
|
||||||
|
|
||||||
const Hint = styled('div', {
|
const Hint = styled('div', {
|
||||||
@@ -25,15 +25,17 @@ const Hint = styled('div', {
|
|||||||
})
|
})
|
||||||
|
|
||||||
export interface KeyboardShortcutHintProps {
|
export interface KeyboardShortcutHintProps {
|
||||||
children: ReactNode
|
hint?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Small reusable bubble used to display and announce keyboard shortcuts,
|
* Small reusable bubble used to display and announce keyboard shortcuts,
|
||||||
* typically when an element receives keyboard focus.
|
* typically when an element receives keyboard focus.
|
||||||
*/
|
*/
|
||||||
export const KeyboardShortcutHint: React.FC<KeyboardShortcutHintProps> = ({
|
export const KeyboardShortcutHint = React.memo(
|
||||||
children,
|
({ hint }: KeyboardShortcutHintProps) => {
|
||||||
}) => {
|
return <Hint>{hint}</Hint>
|
||||||
return <Hint>{children}</Hint>
|
}
|
||||||
}
|
)
|
||||||
|
|
||||||
|
KeyboardShortcutHint.displayName = 'KeyboardShortcutHint'
|
||||||
|
|||||||
@@ -241,13 +241,13 @@ export const ParticipantTile: (
|
|||||||
)}
|
)}
|
||||||
</ParticipantContextIfNeeded>
|
</ParticipantContextIfNeeded>
|
||||||
</TrackRefContextIfNeeded>
|
</TrackRefContextIfNeeded>
|
||||||
<KeyboardShortcutHint>
|
<KeyboardShortcutHint
|
||||||
{t('toolbarHint', {
|
hint={t('toolbarHint', {
|
||||||
shortcut: formatShortcutLabel(
|
shortcut: formatShortcutLabel(
|
||||||
getShortcutDescriptorById('open-shortcuts')?.shortcut
|
getShortcutDescriptorById('open-shortcuts')?.shortcut
|
||||||
),
|
),
|
||||||
})}
|
})}
|
||||||
</KeyboardShortcutHint>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user