Skip to content

armgit / meet

Public Imported from GitHub
0

Open source video conferencing app powered by LiveKit. Built with Django and React.

⚡️(frontend) memoize the KeyboardShortcutHint component

lebaudantoinebf6351e838f2
diff --git a/src/frontend/src/features/rooms/livekit/components/KeyboardShortcutHint.tsx b/src/frontend/src/features/rooms/livekit/components/KeyboardShortcutHint.tsx
index b4502607..dbb39794 100644
--- a/src/frontend/src/features/rooms/livekit/components/KeyboardShortcutHint.tsx
+++ b/src/frontend/src/features/rooms/livekit/components/KeyboardShortcutHint.tsx
@@ -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'
diff --git a/src/frontend/src/features/rooms/livekit/components/ParticipantTile.tsx b/src/frontend/src/features/rooms/livekit/components/ParticipantTile.tsx
index 66c2a0a4..f6e071da 100644
--- a/src/frontend/src/features/rooms/livekit/components/ParticipantTile.tsx
+++ b/src/frontend/src/features/rooms/livekit/components/ParticipantTile.tsx
@@ -241,13 +241,13 @@ export const ParticipantTile: (
)}
</ParticipantContextIfNeeded>
</TrackRefContextIfNeeded>
- <KeyboardShortcutHint>
- {t('toolbarHint', {
+ <KeyboardShortcutHint
+ hint={t('toolbarHint', {
shortcut: formatShortcutLabel(
getShortcutDescriptorById('open-shortcuts')?.shortcut
),
})}
- </KeyboardShortcutHint>
+ />
</div>
)
})