From 1dafb69dc968ef6008af3bdcb371cf79c97ce599 Mon Sep 17 00:00:00 2001 From: Nikita Gordeev Date: Thu, 28 Mar 2019 18:40:21 +0200 Subject: [PATCH] fix(react): add prop componentProps (#9) Added the ability to add component props componentProps --- packages/bbob-react/src/Component.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/bbob-react/src/Component.js b/packages/bbob-react/src/Component.js index 74ca6b2..a49f35f 100644 --- a/packages/bbob-react/src/Component.js +++ b/packages/bbob-react/src/Component.js @@ -5,14 +5,26 @@ import { render } from './render'; const content = (children, plugins, options) => React.Children.map(children, child => (typeof child === 'string' ? render(child, plugins, options) : child)); -const Component = props => - React.createElement(props.container, {}, content(props.children, props.plugins, props.options)); +const Component = ({ + container, + componentProps, + children, + plugins, + options, +}) => React.createElement( + container, + componentProps, + content(children, plugins, options), +); if (process.env.NODE_ENV !== 'production') { Component.propTypes = { container: PropTypes.node, children: PropTypes.node.isRequired, plugins: PropTypes.arrayOf(Function), + componentProps: PropTypes.shape({ + className: PropTypes.string, + }), options: PropTypes.shape({ parser: PropTypes.func, skipParse: PropTypes.bool, @@ -27,6 +39,7 @@ Component.defaultProps = { container: 'span', plugins: [], options: {}, + componentProps: {}, }; export default Component;