vn-verdnaturachat/app/containers/message/Blocks.js

40 lines
792 B
JavaScript
Raw Normal View History

2020-02-11 14:01:35 +00:00
import React from 'react';
import PropTypes from 'prop-types';
import { messageBlockWithContext } from '../UIKit/MessageBlock';
const Blocks = React.memo(({
blocks, id: mid, rid, blockAction
}) => {
if (blocks && blocks.length > 0) {
const [, secondBlock] = blocks;
const { appId = '' } = secondBlock;
return React.createElement(
messageBlockWithContext({
action: async({ actionId, value, blockId }) => {
await blockAction({
actionId,
appId,
value,
blockId,
rid,
mid
});
},
appId,
rid
}), { blocks }
);
}
return null;
});
Blocks.propTypes = {
blocks: PropTypes.array,
id: PropTypes.string,
rid: PropTypes.string,
blockAction: PropTypes.func
};
Blocks.displayName = 'MessageBlocks';
export default Blocks;