Skip to content

Commit

Permalink
better
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Sep 27, 2023
1 parent f145328 commit edb5343
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions docs/data/base/components/portal/portal.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ The following demo shows how a `<span>` nested within a Portal can be appended t

### Server-side

:::error
React doesn't support the [`createPortal()` API](https://react.dev/reference/react-dom/createPortal) on the server.
See [this GitHub issue](https://github.com/facebook/react/issues/13097) for details.
:::

The Portal component cannot be used to render child elements on the server—client-side hydration is necessary.

You need to use the `container` callback as the DOM API isn't available on the server:
The DOM API isn't available on the server, you need to use the `container` prop callback.
This callback is called during a React layout effect:

```jsx
<Portal container={() => document.getElementById('filter-panel')!}>
<Child />
</Portal>
```

:::error
The Portal component cannot be used to render child elements on the server—client-side hydration is necessary.

This is because React doesn't support the [`createPortal()` API](https://react.dev/reference/react-dom/createPortal) on the server.
See [this GitHub issue](https://github.com/facebook/react/issues/13097) for details.
:::

0 comments on commit edb5343

Please sign in to comment.