[MM-56009] Convert ./components/post_view/embedded_bindings/embedded_bindings.tsx from Class Component to Function Component (#25717)

* [MM-56009] Convert `./components/post_view/embedded_bindings/embedded_bindings.tsx` from Class Component to Function Component

* refactor: use Map instead of forEach
This commit is contained in:
Syed Ali Abbas Zaidi 2023-12-14 13:36:28 +05:00 committed by GitHub
parent 917a032baf
commit e644f4e4bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,7 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import React, {memo} from 'react';
import type {AppBinding} from '@mattermost/types/apps';
import type {Post} from '@mattermost/types/posts';
@ -29,31 +29,24 @@ type Props = {
}
export default class EmbeddedBindings extends React.PureComponent<Props> {
static defaultProps = {
imagesMetadata: {},
};
const EmbeddedBindings = ({
embeds,
post,
options,
}: Props) => (
<div
id={`messageAttachmentList_${post.id}`}
className='attachment__list'
>
{embeds.map((embed, i) => (
<EmbeddedBinding
embed={embed}
post={post}
key={'att_' + i}
options={options}
/>
))}
</div>
);
render() {
const content = [] as JSX.Element[];
this.props.embeds.forEach((embed, i) => {
content.push(
<EmbeddedBinding
embed={embed}
post={this.props.post}
key={'att_' + i}
options={this.props.options}
/>,
);
});
return (
<div
id={`messageAttachmentList_${this.props.post.id}`}
className='attachment__list'
>
{content}
</div>
);
}
}
export default memo(EmbeddedBindings);