diff --git a/webapp/channels/src/components/channel_header_dropdown/__snapshots__/channel_header_dropdown.test.tsx.snap b/webapp/channels/src/components/channel_header_dropdown/__snapshots__/channel_header_dropdown.test.tsx.snap
index 743d515c4d..65a59bdc6a 100644
--- a/webapp/channels/src/components/channel_header_dropdown/__snapshots__/channel_header_dropdown.test.tsx.snap
+++ b/webapp/channels/src/components/channel_header_dropdown/__snapshots__/channel_header_dropdown.test.tsx.snap
@@ -643,7 +643,7 @@ exports[`components/ChannelHeaderDropdown should match snapshot with no plugin i
text="Convert to Private Channel"
/>
-
- {
};
it('should match snapshot', () => {
- const wrapper = shallow();
+ const wrapper = shallow();
expect(wrapper).toMatchSnapshot();
});
@@ -35,7 +35,7 @@ describe('components/ChannelHeaderDropdown/MenuItem.LeaveChannel', () => {
...baseProps,
isDefault: true,
};
- const wrapper = shallow();
+ const wrapper = shallow();
expect(wrapper).toMatchSnapshot();
});
@@ -59,7 +59,7 @@ describe('components/ChannelHeaderDropdown/MenuItem.LeaveChannel', () => {
channel: {...baseProps.channel},
actions: {...baseProps.actions},
};
- const wrapper = shallow();
+ const wrapper = shallow();
wrapper.find(Menu.ItemAction).simulate('click', {
preventDefault: jest.fn(),
diff --git a/webapp/channels/src/components/channel_header_dropdown/menu_items/leave_channel/leave_channel.tsx b/webapp/channels/src/components/channel_header_dropdown/menu_items/leave_channel/leave_channel.tsx
index 4d0d0a0be9..e5cfbd5048 100644
--- a/webapp/channels/src/components/channel_header_dropdown/menu_items/leave_channel/leave_channel.tsx
+++ b/webapp/channels/src/components/channel_header_dropdown/menu_items/leave_channel/leave_channel.tsx
@@ -1,7 +1,8 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
-import React from 'react';
+import React, {memo, useCallback} from 'react';
+import {useIntl} from 'react-intl';
import type {Channel} from '@mattermost/types/channels';
@@ -9,7 +10,6 @@ import LeaveChannelModal from 'components/leave_channel_modal';
import Menu from 'components/widgets/menu/menu';
import {Constants, ModalIdentifiers} from 'utils/constants';
-import {localizeMessage} from 'utils/utils';
import type {PropsFromRedux} from './index';
@@ -36,23 +36,21 @@ interface Props extends PropsFromRedux {
id?: string;
}
-export default class LeaveChannel extends React.PureComponent {
- static defaultProps = {
- isDefault: true,
- isGuestUser: false,
- };
+const LeaveChannel = ({
+ isDefault = true,
+ isGuestUser = false,
+ channel,
+ actions: {
+ leaveChannel,
+ openModal,
+ },
+ id,
+}: Props) => {
+ const intl = useIntl();
- handleLeave = (e: Event) => {
+ const handleLeave = useCallback((e: Event) => {
e.preventDefault();
- const {
- channel,
- actions: {
- leaveChannel,
- openModal,
- },
- } = this.props;
-
if (channel.type === Constants.PRIVATE_CHANNEL) {
openModal({
modalId: ModalIdentifiers.LEAVE_PRIVATE_CHANNEL_MODAL,
@@ -64,19 +62,17 @@ export default class LeaveChannel extends React.PureComponent {
} else {
leaveChannel(channel.id);
}
- };
+ }, [channel, leaveChannel, openModal]);
- render() {
- const {channel, isDefault, isGuestUser, id} = this.props;
+ return (
+
+ );
+};
- return (
-
- );
- }
-}
+export default memo(LeaveChannel);