renderer - Handle fragment same way as array

This commit is contained in:
2019-12-22 19:53:11 +05:30
parent 6866d66807
commit 736726805d
+8 -1
View File
@@ -1,5 +1,5 @@
import { root, text } from 'mdast-builder';
import { Children as ReactChildren } from 'react';
import { Children as ReactChildren, Fragment } from 'react';
import * as stringify from 'remark-stringify';
import * as unified from 'unified';
// tslint:disable-next-line: no-implicit-dependencies
@@ -36,6 +36,13 @@ function render(
// Handle (render) Fragment nodes or arrays
node.forEach(fragmentEle => render(fragmentEle, parentASTNodeMod));
} else if (node.type === Fragment) {
const childrenArray = ReactChildren.toArray(
node.props.children
) as ReactElementSubsetWithPrimitive[];
// Render processed array of children
render(childrenArray, parentASTNodeMod);
} else {
const { props, type: elementType } = node;
let processChildren = true;