Use memoized callbacks when passing to components

This commit is contained in:
Daniel Abramov
2023-07-03 18:28:43 +01:00
parent caa3a7e8d0
commit 2293cbf1f0
2 changed files with 19 additions and 7 deletions

View File

@@ -42,6 +42,12 @@ interface Props {
export const CallTypeDropdown: FC<Props> = ({ callType, setCallType }) => {
const { t } = useTranslation();
const onAction = (key: React.Key) => {
setCallType(key.toString() as CallType);
};
const onClose = () => {};
return (
<PopoverMenuTrigger placement="bottom">
<Button variant="dropdown" className={commonStyles.headline}>
@@ -55,11 +61,8 @@ export const CallTypeDropdown: FC<Props> = ({ callType, setCallType }) => {
<Menu
{...props}
label={t("Call type menu")}
onAction={(key) => {
const callType = key.toString();
setCallType(callType as CallType);
}}
onClose={() => {}}
onAction={onAction}
onClose={onClose}
>
<Item key={CallType.Video} textValue={t("Video call")}>
<VideoIcon />