⚡️(frontend) avoid non-primitive default props recreation on each render
The empty object literal created a new reference every render, potentially triggering unnecessary re-renders. Hoist an EMPTY_PROPS constant to the module level and reuse it instead of allocating a new object.
This commit is contained in:
committed by
aleb_the_flash
parent
6e3845d0c1
commit
ca9c7fc152
@@ -22,6 +22,8 @@ export type VideoTabProps = Pick<DialogProps, 'onOpenChange'> &
|
||||
|
||||
type DeviceItems = Array<{ value: string; label: string }>
|
||||
|
||||
const EMPTY_PROPS = {}
|
||||
|
||||
export const VideoTab = ({ id }: VideoTabProps) => {
|
||||
const { t } = useTranslation('settings', { keyPrefix: 'video' })
|
||||
const { localParticipant, remoteParticipants } = useRoomContext()
|
||||
@@ -59,7 +61,7 @@ export const VideoTab = ({ id }: VideoTabProps) => {
|
||||
const isCamEnabled = devicesIn?.length > 0
|
||||
|
||||
const disabledProps = isCamEnabled
|
||||
? {}
|
||||
? EMPTY_PROPS
|
||||
: {
|
||||
placeholder: t('permissionsRequired'),
|
||||
isDisabled: true,
|
||||
|
||||
Reference in New Issue
Block a user