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 ActiveSpeaker component

lebaudantoine4b393e28cacf
diff --git a/src/frontend/src/features/rooms/components/ActiveSpeaker.tsx b/src/frontend/src/features/rooms/components/ActiveSpeaker.tsx
index d681019f..3d5748c6 100644
--- a/src/frontend/src/features/rooms/components/ActiveSpeaker.tsx
+++ b/src/frontend/src/features/rooms/components/ActiveSpeaker.tsx
@@ -1,3 +1,4 @@
+import React from 'react'
import { styled } from '@/styled-system/jsx'
const StyledContainer = styled('div', {
@@ -67,35 +68,36 @@ export type ActiveSpeakerProps = {
pushToTalk?: boolean
}
-export const ActiveSpeaker = ({
- isSpeaking,
- pushToTalk,
-}: ActiveSpeakerProps) => {
- return (
- <StyledContainer pushToTalk={pushToTalk}>
- <StyledChild
- pushToTalk={pushToTalk}
- active={isSpeaking}
- size="small"
- style={{
- animationDelay: '300ms',
- }}
- />
- <StyledChild
- pushToTalk={pushToTalk}
- active={isSpeaking}
- style={{
- animationDelay: '100ms',
- }}
- />
- <StyledChild
- pushToTalk={pushToTalk}
- active={isSpeaking}
- size="small"
- style={{
- animationDelay: '500ms',
- }}
- />
- </StyledContainer>
- )
-}
+export const ActiveSpeaker = React.memo(
+ ({ isSpeaking, pushToTalk }: ActiveSpeakerProps) => {
+ return (
+ <StyledContainer pushToTalk={pushToTalk}>
+ <StyledChild
+ pushToTalk={pushToTalk}
+ active={isSpeaking}
+ size="small"
+ style={{
+ animationDelay: '300ms',
+ }}
+ />
+ <StyledChild
+ pushToTalk={pushToTalk}
+ active={isSpeaking}
+ style={{
+ animationDelay: '100ms',
+ }}
+ />
+ <StyledChild
+ pushToTalk={pushToTalk}
+ active={isSpeaking}
+ size="small"
+ style={{
+ animationDelay: '500ms',
+ }}
+ />
+ </StyledContainer>
+ )
+ }
+)
+
+ActiveSpeaker.displayName = 'ActiveSpeaker'