Skip to content

Commit

Permalink
also address case of array return
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed May 23, 2024
1 parent 8875ca9 commit b64e462
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function renderToString(vnode, context, _rendererState) {
parent[CHILDREN] = [vnode];

try {
return _renderToString(
const rendered = _renderToString(
vnode,
context || EMPTY_OBJ,
false,
Expand All @@ -64,6 +64,11 @@ export function renderToString(vnode, context, _rendererState) {
false,
_rendererState
);

if (Array.isArray(rendered)) {
return rendered.join('');
}
return rendered;
} catch (e) {
if (e.then) {
throw new Error('Use "renderToStringAsync" for suspenseful rendering.');
Expand Down Expand Up @@ -590,7 +595,7 @@ function _renderToString(
break;

case 'dangerouslySetInnerHTML':
html = v && v.__html != null ? v.__html : '';
html = v && v.__html;
continue;

// serialize object styles to a CSS string
Expand Down Expand Up @@ -682,7 +687,6 @@ function _renderToString(

if (Array.isArray(html)) return [startTag, ...html, endTag];
else if (typeof html !== 'string') return [startTag, html, endTag];

return startTag + html + endTag;
}

Expand Down

0 comments on commit b64e462

Please sign in to comment.