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

21 lines (19 loc) 598 B
import React from 'react'; import _ from 'lodash'; import AppContext from '../common/app-context'; export default (Component, fields = []) => { return (props) => ( <AppContext.Consumer> {({ state }) => { let stateProps = {}; fields = _.isString(fields) ? [fields] : fields; if (fields.length === 0) { stateProps = { ...state }; } else { fields.forEach(field => stateProps[field] = state[field]); } return <Component {...props} {...stateProps}>{props.children}</Component>; }} </AppContext.Consumer> ); };