Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update readme for suspense rendering #338

Merged
merged 1 commit into from
Mar 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading