Skip to content

Commit

Permalink
Use startTransition for hydrateRoot to opt-in to non-blocking hydrati…
Browse files Browse the repository at this point in the history
…on (#40874)

As per @sebmarkbage's recommendation.



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
  • Loading branch information
timneutkens committed Sep 24, 2022
1 parent bf0827d commit 50ab2e4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/next/client/app-index.tsx
Expand Up @@ -186,7 +186,9 @@ export function hydrate() {
const isError = document.documentElement.id === '__next_error__'
const reactRoot = isError
? (ReactDOMClient as any).createRoot(appElement)
: (ReactDOMClient as any).hydrateRoot(appElement, reactEl)
: (React as any).startTransition(() =>
(ReactDOMClient as any).hydrateRoot(appElement, reactEl)
)
if (isError) {
reactRoot.render(reactEl)
}
Expand Down

0 comments on commit 50ab2e4

Please sign in to comment.