mirror of
https://github.com/tenrok/BBob.git
synced 2026-06-11 18:02:26 +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 =>
|
const content = (children, plugins, options) => React.Children.map(children, child =>
|
||||||
(typeof child === 'string' ? render(child, plugins, options) : child));
|
(typeof child === 'string' ? render(child, plugins, options) : child));
|
||||||
|
|
||||||
const Component = props =>
|
const Component = ({
|
||||||
React.createElement(props.container, {}, content(props.children, props.plugins, props.options));
|
container,
|
||||||
|
componentProps,
|
||||||
|
children,
|
||||||
|
plugins,
|
||||||
|
options,
|
||||||
|
}) => React.createElement(
|
||||||
|
container,
|
||||||
|
componentProps,
|
||||||
|
content(children, plugins, options),
|
||||||
|
);
|
||||||
|
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
Component.propTypes = {
|
Component.propTypes = {
|
||||||
container: PropTypes.node,
|
container: PropTypes.node,
|
||||||
children: PropTypes.node.isRequired,
|
children: PropTypes.node.isRequired,
|
||||||
plugins: PropTypes.arrayOf(Function),
|
plugins: PropTypes.arrayOf(Function),
|
||||||
|
componentProps: PropTypes.shape({
|
||||||
|
className: PropTypes.string,
|
||||||
|
}),
|
||||||
options: PropTypes.shape({
|
options: PropTypes.shape({
|
||||||
parser: PropTypes.func,
|
parser: PropTypes.func,
|
||||||
skipParse: PropTypes.bool,
|
skipParse: PropTypes.bool,
|
||||||
@@ -27,6 +39,7 @@ Component.defaultProps = {
|
|||||||
container: 'span',
|
container: 'span',
|
||||||
plugins: [],
|
plugins: [],
|
||||||
options: {},
|
options: {},
|
||||||
|
componentProps: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Component;
|
export default Component;
|
||||||
|
|||||||
Reference in New Issue
Block a user