2
0
mirror of https://github.com/tenrok/BBob.git synced 2026-05-15 11:59:37 +03:00

fix(react): add prop componentProps (#9)

Added the ability to add component props componentProps
This commit is contained in:
Nikita Gordeev
2019-03-28 18:40:21 +02:00
committed by Nikolay Kostyurin
parent a8d3c496a3
commit 1dafb69dc9
+15 -2
View File
@@ -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;