From 0b39f5d715b5d92b50d4cf15d213b5bfbb59a83e Mon Sep 17 00:00:00 2001 From: Robin van der Vleuten Date: Fri, 3 Aug 2018 10:08:42 +0200 Subject: [PATCH] Made component compatible with React.createElement --- src/index.js | 3 ++- src/markup-to-vdom.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 92585bf..9d073a1 100644 --- a/src/index.js +++ b/src/index.js @@ -25,7 +25,8 @@ export default class Markup extends Component { } } - render({ wrap=true, type, markup, components, reviver, onError, 'allow-scripts':allowScripts, 'allow-events':allowEvents, trim, ...props }) { + render() { + let { wrap=true, type, markup, components, reviver, onError, 'allow-scripts':allowScripts, 'allow-events':allowEvents, trim, ...props } = this.props; let h = reviver || this.reviver || this.constructor.prototype.reviver || customReviver || defaultReviver, vdom; diff --git a/src/markup-to-vdom.js b/src/markup-to-vdom.js index 552a5a7..ec2b381 100644 --- a/src/markup-to-vdom.js +++ b/src/markup-to-vdom.js @@ -21,8 +21,8 @@ export default function markupToVdom(markup, type, reviver, map, options) { let vdom = body && toVdom(body, visitor, reviver, options); visitor.map = null; - - return vdom && vdom.children || null; + // Return VDOM children for reviver (Preact uses children where React uses props.children). + return vdom && (vdom.children || vdom.props.children) || null; } function toCamelCase(name) {