Migrate ./components/channel_header_mobile/show_search_button/show_search_button.tsx from Class component to functional component (#25636)

* chore: migrate show_search_button.tsx to functional component

* chore: styled show_search_button to match the pattern

* test: updated snapshots
Этот коммит содержится в:
Aditi Patel
2023-12-12 04:17:25 -06:00
коммит произвёл GitHub
родитель e0b5b951f1
Коммит 07bf343e46
2 изменённых файлов: 22 добавлений и 23 удалений

Просмотреть файл

@@ -42,7 +42,7 @@ exports[`components/ChannelHeaderMobile/ChannelHeaderMobile should match snapsho
}
}
/>
<Connect(ShowSearchButton) />
<Connect(Component) />
<Connect(injectIntl(MobileChannelHeaderPlug))
channel={
Object {
@@ -113,7 +113,7 @@ exports[`components/ChannelHeaderMobile/ChannelHeaderMobile should match snapsho
}
}
/>
<Connect(ShowSearchButton) />
<Connect(Component) />
<Connect(injectIntl(MobileChannelHeaderPlug))
channel={
Object {
@@ -184,7 +184,7 @@ exports[`components/ChannelHeaderMobile/ChannelHeaderMobile should match snapsho
}
}
/>
<Connect(ShowSearchButton) />
<Connect(Component) />
<Connect(injectIntl(MobileChannelHeaderPlug))
channel={
Object {
@@ -255,7 +255,7 @@ exports[`components/ChannelHeaderMobile/ChannelHeaderMobile should match snapsho
}
}
/>
<Connect(ShowSearchButton) />
<Connect(Component) />
<Connect(injectIntl(MobileChannelHeaderPlug))
channel={
Object {

Просмотреть файл

@@ -15,24 +15,23 @@ type Props = {
actions: Actions;
}
export default class ShowSearchButton extends React.PureComponent<Props> {
handleClick = () => {
this.props.actions.openRHSSearch();
const ShowSearchButton = ({actions}: Props) => {
const handleClick = () => {
actions.openRHSSearch();
};
render() {
return (
<button
type='button'
className='navbar-toggle navbar-right__icon navbar-search pull-right'
onClick={this.handleClick}
aria-label={localizeMessage('accessibility.button.Search', 'Search')}
>
<SearchIcon
className='icon icon__search'
aria-hidden='true'
/>
</button>
);
}
}
return (
<button
type='button'
className='navbar-toggle navbar-right__icon navbar-search pull-right'
onClick={handleClick}
aria-label={localizeMessage('accessibility.button.Search', 'Search')}
>
<SearchIcon
className='icon icon__search'
aria-hidden='true'
/>
</button>
);
};
export default React.memo(ShowSearchButton);