Skip to content

Commit 925383e

Browse files
committed
Update docs
- remove implementation details - mention `identifierPrefix`
1 parent 43e5481 commit 925383e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

packages/dev/docs/pages/react-aria/ssr.mdx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,21 @@ When strict mode is enabled on React 16 or 17, it generates different IDs betwee
4444

4545
## Automatic ID Generation
4646

47+
### React 18
48+
4749
If you are using React 18, React Aria uses [React.useId](https://reactjs.org/docs/hooks-reference.html#useid) to generate unique IDs that are stable across the client and server.
4850

51+
If your React app have multiple roots, you need to configure `identifierPrefix` option on `hydrateRoot` and `ReactDOMServer` to prevent collisions. For more information, please see the documentation of [React.useId](https://reactjs.org/docs/hooks-reference.html#useid).
52+
53+
### React 16 and 17
54+
4955
If you are using React 16 or 17, React Aria tries to generate consistent IDs by itself. In this case, when using SSR, only a single copy of React Aria can be on the page at a time, and React StrictMode cannot be supported.
5056

51-
If you use React Aria’s [useId](useId.html) hook in your own components, `SSRProvider` will ensure the ids are consistent when server rendered. No additional changes in each component are required to enable
52-
SSR support.
57+
You may use React Aria’s [useId](useId.html) hook in your own components. `SSRProvider` will ensure the ids are consistent when server rendered. No additional changes in each component are required to enable SSR support.
5358

5459
## SSR specific rendering
5560

56-
You can also use the [useIsSSR](useIsSSR.html) hook in your own components to determine whether they are running in an SSR context. This hook returns `true` both during server rendering and hydration, but updates immediately to `false` after hydration. You can use this to delay browser-specific code like media queries and feature detection until after the client has hydrated.
61+
You can use the [useIsSSR](useIsSSR.html) hook in your own components to determine whether they are running in an SSR context. This hook returns `true` both during server rendering and hydration, but updates immediately to `false` after hydration. You can use this to delay browser-specific code like media queries and feature detection until after the client has hydrated.
5762

5863
```tsx
5964
import {useIsSSR} from '@react-aria/ssr';

packages/dev/docs/pages/react-spectrum/ssr.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Wrapping your application in an `SSRProvider` ensures that the HTML generated on
4545
Note that `SSRProvider` doesn't support [strict mode](https://reactjs.org/docs/strict-mode.html) on React 16 and 17.
4646
When strict mode is enabled on React 16 or 17, it generates different IDs between server and client. That results in hydration errors.
4747

48-
When using SSR, only a single copy of React Spectrum can be on the page at a time. This is in contrast to client-side rendering, where multiple copies from different parts of an app can coexist. Internally, many components rely on auto-generated ids to link related elements via ARIA attributes. When server side rendering, these ids need to be consistent so they match between the server and client, and this would not be possible with multiple copies of React Spectrum.
48+
When using SSR, only a single copy of React Spectrum can be on the page at a time. If you are using React 18, you may configure `identifierPrefix` option on `hydrateRoot` and `ReactDOMServer` to bypass this restriction. For more information, please see the documentation of [React.useId](https://reactjs.org/docs/hooks-reference.html#useid).
4949

5050
Media queries and DOM feature detection cannot be performed on the server because they depend on specific browser parameters that aren’t sent as part of the request. In cases where these affect the rendering of a particular component, this check is delayed until just after hydration is completed. This ensures that the rendering is consistent between the server and hydrated DOM, but updated immediately after the page becomes interactive.
5151

0 commit comments

Comments
 (0)