mirror of
https://github.com/mattermost/mattermost.git
synced 2026-05-28 04:35:04 -04:00
[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:
parent
917a032baf
commit
e644f4e4bb
1 changed files with 21 additions and 28 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue