From 253c5c7df7256414fc2dcaa95c37e7ee97750ac1 Mon Sep 17 00:00:00 2001 From: Fatih Altinok Date: Mon, 18 Jul 2022 17:29:33 +0300 Subject: [PATCH 1/3] fix: Fallback to setTimeout if rIC isn't available --- app/entry.client.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/entry.client.tsx b/app/entry.client.tsx index 51574644..438675ff 100644 --- a/app/entry.client.tsx +++ b/app/entry.client.tsx @@ -2,7 +2,7 @@ import * as React from "react"; import { RemixBrowser } from "@remix-run/react"; import { hydrateRoot } from "react-dom/client"; -requestIdleCallback(() => { +function mount() { React.startTransition(() => { hydrateRoot( document, @@ -11,4 +11,10 @@ requestIdleCallback(() => { ); }); -}); +} + +if (window.requestIdleCallback) { + window.requestIdleCallback(mount) +} else { + window.setTimeout(mount, 1) +} \ No newline at end of file From 32af45d86d36bfd461a9b244cc53581e1ad3c017 Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Mon, 18 Jul 2022 11:14:40 -0600 Subject: [PATCH 2/3] Update app/entry.client.tsx --- app/entry.client.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/entry.client.tsx b/app/entry.client.tsx index 438675ff..3a897395 100644 --- a/app/entry.client.tsx +++ b/app/entry.client.tsx @@ -2,7 +2,7 @@ import * as React from "react"; import { RemixBrowser } from "@remix-run/react"; import { hydrateRoot } from "react-dom/client"; -function mount() { +function hydrate() { React.startTransition(() => { hydrateRoot( document, From ba60bffafd1dee5c2fc3a124778d6d332c46d540 Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Mon, 18 Jul 2022 11:14:44 -0600 Subject: [PATCH 3/3] Update app/entry.client.tsx --- app/entry.client.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/entry.client.tsx b/app/entry.client.tsx index 3a897395..6acd4cbe 100644 --- a/app/entry.client.tsx +++ b/app/entry.client.tsx @@ -14,7 +14,7 @@ function hydrate() { } if (window.requestIdleCallback) { - window.requestIdleCallback(mount) + window.requestIdleCallback(hydrate) } else { - window.setTimeout(mount, 1) -} \ No newline at end of file + window.setTimeout(hydrate, 1) +}