Epic React V2

Eager Loading

Example of coding added at lazy page.tsx to load the Globe component eagerly.

The Globe component is imported lazily, but the code to load it is executed when the checkbox is focused or hovered over.

(The changes that are committed)

const loadGlobe = () => import('@/components/globe/globe');
const Globe = lazy(loadGlobe);

<Label
  style={{ marginBottom: '1rem' }}
  onFocus={loadGlobe}
  onPointerEnter={loadGlobe}
>
  <input
    type="checkbox"
    checked={showGlobe}
    onChange={(e) => setShowGlobe(e.currentTarget.checked)}
  />
</Label>