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:
committed by
Nikolay Kostyurin
parent
a8d3c496a3
commit
1dafb69dc9
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user