Skip to content

Commit

Permalink
fix: Fallback to setTimeout if rIC isn't available (remix-run#125)
Browse files Browse the repository at this point in the history
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
  • Loading branch information
frontsideair and kentcdodds authored Jul 18, 2022
1 parent 57fc0b3 commit 0ae0403
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/entry.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from "react";
import { RemixBrowser } from "@remix-run/react";
import { hydrateRoot } from "react-dom/client";

requestIdleCallback(() => {
function hydrate() {
React.startTransition(() => {
hydrateRoot(
document,
Expand All @@ -11,4 +11,10 @@ requestIdleCallback(() => {
</React.StrictMode>
);
});
});
}

if (window.requestIdleCallback) {
window.requestIdleCallback(hydrate)
} else {
window.setTimeout(hydrate, 1)
}

0 comments on commit 0ae0403

Please sign in to comment.