UNPKG

node-red-contrib-chatbot

Version:

REDBot a Chat bot for a full featured chat bot for Telegram, Facebook Messenger and Slack. Almost no coding skills required

40 lines (31 loc) 1.01 kB
import React, { Fragment} from 'react'; import PropTypes from 'prop-types'; import isFunction from '../helpers/is-function'; import PlugItContext from '../context'; class Items extends React.Component { static contextType = PlugItContext; static propTypes = { region: PropTypes.string, children: PropTypes.func }; render() { const { region, children: renderProp } = this.props; // eslint-disable-next-line no-unused-vars const { region: _region, ...rest } = this.props; const { plugins } = this.context; const collection = plugins .map(plugin => { return (plugin.getViews(region) || []).map(item => { return { view: item.view, props: isFunction(item.props) ? item.props(rest) : item.props, plugin }; }); }) .reduce((a, v) => a.concat(v), []) //flatten .filter(Boolean); //compact return <Fragment>{renderProp(collection)}</Fragment>; } } export default Items;