Skip to content

Commit

Permalink
use setTimeout instead of idleCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
jablonski committed Aug 24, 2023
1 parent 3b5b980 commit 4fac275
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ export function render(components, root, callback) {
callback();
}
};
if ("requestIdleCallback" in window) {
createRoot(root).render(parse(components, root));
window.requestIdleCallback(restoreCallback);
} else {
if (
navigator.userAgent.includes("Safari") &&
!navigator.userAgent.includes("Chrome")
) {
ReactDOM.render(parse(components, root), root, restoreCallback);
} else {
createRoot(root).render(parse(components, root));
setTimeout(restoreCallback, 0);
}
}
}
Expand Down

0 comments on commit 4fac275

Please sign in to comment.