diff --git a/.changeset/famous-experts-decide.md b/.changeset/famous-experts-decide.md new file mode 100644 index 00000000..476006ab --- /dev/null +++ b/.changeset/famous-experts-decide.md @@ -0,0 +1,5 @@ +--- +'preact-render-to-string': patch +--- + +Fix issue where preactRenderToString returns a promise of a promise diff --git a/src/index.js b/src/index.js index 9dec64ab..743f25aa 100644 --- a/src/index.js +++ b/src/index.js @@ -109,7 +109,7 @@ export async function renderToStringAsync(vnode, context) { parent[CHILDREN] = [vnode]; try { - const rendered = _renderToString( + const rendered = await _renderToString( vnode, context || EMPTY_OBJ, false, diff --git a/test/compat/async.test.jsx b/test/compat/async.test.jsx index 8b50c001..968c12b1 100644 --- a/test/compat/async.test.jsx +++ b/test/compat/async.test.jsx @@ -1,6 +1,6 @@ import { renderToStringAsync } from '../../src/index.js'; -import { h } from 'preact'; -import { Suspense, useId } from 'preact/compat'; +import { h, Fragment } from 'preact'; +import { Suspense, useId, lazy, createContext } from 'preact/compat'; import { expect } from 'chai'; import { createSuspender } from '../utils.jsx'; @@ -26,10 +26,14 @@ describe('Async renderToString', () => { }); it('should render JSX with nested suspended components', async () => { - const { Suspender: SuspenderOne, suspended: suspendedOne } = - createSuspender(); - const { Suspender: SuspenderTwo, suspended: suspendedTwo } = - createSuspender(); + const { + Suspender: SuspenderOne, + suspended: suspendedOne + } = createSuspender(); + const { + Suspender: SuspenderTwo, + suspended: suspendedTwo + } = createSuspender(); const promise = renderToStringAsync(