Skip to content

Commit

Permalink
Merge pull request #338 from preactjs/readme-suspense
Browse files Browse the repository at this point in the history
chore: Update readme for suspense rendering
  • Loading branch information
marvinhagemeister authored Mar 17, 2024
2 parents a50c93d + ffa8ea2 commit 5441664
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ options.errorBoundaries = true;

---

### `Suspense` & `lazy` components with [`preact/compat`](https://www.npmjs.com/package/preact) & [`preact-ssr-prepass`](https://www.npmjs.com/package/preact-ssr-prepass)
### `Suspense` & `lazy` components with [`preact/compat`](https://www.npmjs.com/package/preact)

```bash
npm install preact preact-render-to-string preact-ssr-prepass
npm install preact preact-render-to-string
```

```jsx
Expand All @@ -125,19 +125,12 @@ const Main = () => {
```

```jsx
import { render } from 'preact-render-to-string';
import prepass from 'preact-ssr-prepass';
import { renderToStringAsync } from 'preact-render-to-string';
import { Main } from './main';

const main = async () => {
// Creation of the virtual DOM
const vdom = <Main />;

// Pre-rendering of lazy components
await prepass(vdom);

// Rendering of components
const html = render(vdom);
// Rendering of lazy components
const html = await renderToStringAsync(<Main />);

console.log(html);
// <h1>Home page</h1>
Expand Down

0 comments on commit 5441664

Please sign in to comment.