[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
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
917a032baf
Коммит
e644f4e4bb
@@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||||
// See LICENSE.txt for license information.
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
import React from 'react';
|
import React, {memo} from 'react';
|
||||||
|
|
||||||
import type {AppBinding} from '@mattermost/types/apps';
|
import type {AppBinding} from '@mattermost/types/apps';
|
||||||
import type {Post} from '@mattermost/types/posts';
|
import type {Post} from '@mattermost/types/posts';
|
||||||
@@ -29,31 +29,24 @@ type Props = {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class EmbeddedBindings extends React.PureComponent<Props> {
|
const EmbeddedBindings = ({
|
||||||
static defaultProps = {
|
embeds,
|
||||||
imagesMetadata: {},
|
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() {
|
export default memo(EmbeddedBindings);
|
||||||
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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user