diff --git a/webapp/channels/src/components/widgets/settings/radio_setting.tsx b/webapp/channels/src/components/widgets/settings/radio_setting.tsx index 9db09801e6..b193586022 100644 --- a/webapp/channels/src/components/widgets/settings/radio_setting.tsx +++ b/webapp/channels/src/components/widgets/settings/radio_setting.tsx @@ -1,13 +1,14 @@ // 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 type {ChangeEventHandler} from 'react'; import Setting from './setting'; type Props = { id: string; - options: Array<{text: string; value: string}>; + options?: Array<{text: string; value: string}>; label: React.ReactNode; onChange(name: string, value: any): void; value?: string; @@ -17,48 +18,51 @@ type Props = { } -export default class RadioSetting extends React.PureComponent { - public static defaultProps: Partial = { - labelClassName: '', - inputClassName: '', - options: [], - }; +const RadioSetting = ({ + labelClassName = '', + inputClassName = '', + options = [], + onChange, + id, + label, + helpText, + value, +}: Props) => { + const handleChange: ChangeEventHandler = useCallback((e) => { + onChange(id, e.target.value); + }, [onChange, id]); - private handleChange: React.ChangeEventHandler = (e) => { - this.props.onChange(this.props.id, e.target.value); - }; + return ( + + { + options.map(({value: option, text}) => { + return ( +
+ +
+ ); + }) + } +
+ ); +}; - public render(): JSX.Element { - return ( - - { - this.props.options.map(({value, text}) => { - return ( -
- -
- ); - }) - } -
- ); - } -} +export default memo(RadioSetting);