Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjaiyan-dev authored Aug 16, 2022
1 parent aeb71c1 commit 7d22519
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions packages/integrations/react/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,6 @@ import { createElement, startTransition } from 'react';
import { createRoot, hydrateRoot } from 'react-dom/client';
import StaticHtml from './static-html.js';

/**requestIdleCallback pollyfill https://developer.chrome.com/blog/using-requestidlecallback/#checking-for-requestidlecallback */
window?.requestIdleCallback = window?.requestIdleCallback || function (cb) {
var start = Date.now();
return setTimeout(function () {
cb({
didTimeout: false,
timeRemaining: function () {
return Math.max(0, 50 - (Date.now() - start));
}
});
}, 1);
}

function isAlreadyHydrated(element) {
for (const key in element) {
if (key.startsWith('__reactContainer')) {
Expand Down Expand Up @@ -44,9 +31,7 @@ export default (element) =>
createRoot(element).render(componentEl);
})
}
return window?.requestIdleCallback(() => {
startTransition(() => {
hydrateRoot(element, componentEl);
})
return startTransition(() => {
hydrateRoot(element, componentEl);
})
};

0 comments on commit 7d22519

Please sign in to comment.