Skip to content

Commit

Permalink
- Accessing 'window' during module initialization can cause issues i…
Browse files Browse the repository at this point in the history
…n non-browser environment.

 - Moving the scheuduler access inside the component. It is assumed that this would not be used
   in a non-browser environment.
  • Loading branch information
aroramayur committed Mar 20, 2024
1 parent 122da92 commit e4c45c0
Showing 1 changed file with 4 additions and 2 deletions.
Expand Up @@ -18,8 +18,7 @@ import { ProfilerContext } from '../../profiler';
import type { Status } from './types';
import { useSubscription } from './utils';

// @ts-expect-error requestIdleCallback might not exist
const { requestIdleCallback = setTimeout } = window;

Check failure on line 21 in packages/core/react-loosely-lazy/src/lazy/components/client.tsx

View workflow job for this annotation

GitHub Actions / build (16.x)

Delete `⏎⏎`

Check failure on line 21 in packages/core/react-loosely-lazy/src/lazy/components/client.tsx

View workflow job for this annotation

GitHub Actions / build (16.x)

Delete `⏎⏎`

export function createComponentClient<C extends ComponentType<any>>({
defer,
Expand All @@ -32,6 +31,9 @@ export function createComponentClient<C extends ComponentType<any>>({
dataLazyId: string;
moduleId: string;
}) {

Check failure on line 33 in packages/core/react-loosely-lazy/src/lazy/components/client.tsx

View workflow job for this annotation

GitHub Actions / build (16.x)

Delete `⏎··`

Check failure on line 33 in packages/core/react-loosely-lazy/src/lazy/components/client.tsx

View workflow job for this annotation

GitHub Actions / build (16.x)

Delete `⏎··`

// @ts-expect-error requestIdleCallback might not exist
const { requestIdleCallback = setTimeout } = window;
const ResolvedLazy = lazy(() => deferred.promise);

return (props: ComponentProps<C>) => {
Expand Down

0 comments on commit e4c45c0

Please sign in to comment.