Skip to content

Commit

Permalink
Merge pull request #43365 from rezkiy37/refactor/43352-extra-updates-…
Browse files Browse the repository at this point in the history
…workspace-switch-button

Reduce re-renders of WorkspaceSwitcherButton
  • Loading branch information
Julesssss authored Jun 10, 2024
2 parents 350b7ab + 02d3efd commit 4417f99
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/components/WorkspaceSwitcherButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useMemo, useRef} from 'react';
import React, {memo, useMemo, useRef} from 'react';
import type {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import useLocalize from '@hooks/useLocalize';
Expand Down Expand Up @@ -26,7 +26,7 @@ function WorkspaceSwitcherButton({policy}: WorkspaceSwitcherButtonProps) {

const pressableRef = useRef<View>(null);

const {source, name, type, id} = useMemo(() => {
const mainAvatar = useMemo(() => {
if (!policy) {
return {source: Expensicons.ExpensifyAppIcon, name: CONST.WORKSPACE_SWITCHER.NAME, type: CONST.ICON_TYPE_AVATAR};
}
Expand Down Expand Up @@ -56,7 +56,7 @@ function WorkspaceSwitcherButton({policy}: WorkspaceSwitcherButtonProps) {
>
{({hovered}) => (
<SubscriptAvatar
mainAvatar={{source, name, type, id}}
mainAvatar={mainAvatar}
subscriptIcon={{
source: Expensicons.DownArrow,
width: CONST.WORKSPACE_SWITCHER.SUBSCRIPT_ICON_SIZE,
Expand All @@ -75,4 +75,4 @@ function WorkspaceSwitcherButton({policy}: WorkspaceSwitcherButtonProps) {

WorkspaceSwitcherButton.displayName = 'WorkspaceSwitcherButton';

export default WorkspaceSwitcherButton;
export default memo(WorkspaceSwitcherButton);

0 comments on commit 4417f99

Please sign in to comment.