Use memoized callbacks when passing to components
This commit is contained in:
@@ -42,6 +42,12 @@ interface Props {
|
|||||||
export const CallTypeDropdown: FC<Props> = ({ callType, setCallType }) => {
|
export const CallTypeDropdown: FC<Props> = ({ callType, setCallType }) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const onAction = (key: React.Key) => {
|
||||||
|
setCallType(key.toString() as CallType);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onClose = () => {};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PopoverMenuTrigger placement="bottom">
|
<PopoverMenuTrigger placement="bottom">
|
||||||
<Button variant="dropdown" className={commonStyles.headline}>
|
<Button variant="dropdown" className={commonStyles.headline}>
|
||||||
@@ -55,11 +61,8 @@ export const CallTypeDropdown: FC<Props> = ({ callType, setCallType }) => {
|
|||||||
<Menu
|
<Menu
|
||||||
{...props}
|
{...props}
|
||||||
label={t("Call type menu")}
|
label={t("Call type menu")}
|
||||||
onAction={(key) => {
|
onAction={onAction}
|
||||||
const callType = key.toString();
|
onClose={onClose}
|
||||||
setCallType(callType as CallType);
|
|
||||||
}}
|
|
||||||
onClose={() => {}}
|
|
||||||
>
|
>
|
||||||
<Item key={CallType.Video} textValue={t("Video call")}>
|
<Item key={CallType.Video} textValue={t("Video call")}>
|
||||||
<VideoIcon />
|
<VideoIcon />
|
||||||
|
|||||||
@@ -38,6 +38,15 @@ export function GridLayoutMenu({ layout, setLayout }: Props) {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const tooltip = useCallback(() => t("Change layout"), [t]);
|
const tooltip = useCallback(() => t("Change layout"), [t]);
|
||||||
|
|
||||||
|
const onAction = useCallback(
|
||||||
|
(key: React.Key) => {
|
||||||
|
setLayout(key.toString() as Layout);
|
||||||
|
},
|
||||||
|
[setLayout]
|
||||||
|
);
|
||||||
|
|
||||||
|
const onClose = useCallback(() => {}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PopoverMenuTrigger placement="bottom right">
|
<PopoverMenuTrigger placement="bottom right">
|
||||||
<TooltipTrigger tooltip={tooltip}>
|
<TooltipTrigger tooltip={tooltip}>
|
||||||
@@ -49,8 +58,8 @@ export function GridLayoutMenu({ layout, setLayout }: Props) {
|
|||||||
<Menu
|
<Menu
|
||||||
{...props}
|
{...props}
|
||||||
label={t("Grid layout menu")}
|
label={t("Grid layout menu")}
|
||||||
onAction={(key) => setLayout(key.toString() as Layout)}
|
onAction={onAction}
|
||||||
onClose={() => {}}
|
onClose={onClose}
|
||||||
>
|
>
|
||||||
<Item key="freedom" textValue={t("Freedom")}>
|
<Item key="freedom" textValue={t("Freedom")}>
|
||||||
<FreedomIcon />
|
<FreedomIcon />
|
||||||
|
|||||||
Reference in New Issue
Block a user