0

I am trying to import a component onto a page and the component uses a package that uses the window property. So, I need to dynamically import the component.

How can I do the following with Gatsby? (This is in NextJS)

import dynamic from 'next/dynamic';
...
const MyComponent = dynamic(() =>
    import('path').then((comp) => comp.default),
  );
yankeedoodle
  • 353
  • 2
  • 11

1 Answers1

0

You need to append your js script to your component. window property is not native. Check it, for example, here

illia chill
  • 1,652
  • 7
  • 11
  • I'm not sure I understand how this solves it. Window is used by a package dependency (powerbi-client) and I need to dynamically import a component I built (that relies on that package). – yankeedoodle Mar 22 '22 at 17:24