Topic: Install with latest next.js : ReferenceError: window is not defined

cariforef priority asked 2 years ago


Hello,

I can not make mdb react version 4 work with Next.js. I get : error - ReferenceError: window is not defined

can you help me ? Thanks. Didier


Krzysztof Wilk staff commented 2 years ago

Hi!

We don't guarantee the proper working of our package with the Next.js at this moment. The integration is planned for the near future. Anyway - can you share your code with me? Maybe I'll be able to help :)


cariforef priority commented 2 years ago

Hello Krzysztof,

Do you have a date planned for this integration ? Thanks.


Krzysztof Wilk staff commented 2 years ago

Hi!

Unfortunately, we don't have planned it yet.


jlopez994 free answered 2 years ago


Hi,

I have the same issue. It seems it comes from this line (node_modules/mdb-react-ui-kit/dist/mdb-react-ui-kit.js:1:39365):

Le.defaultProps={offset:10,container:window}

So a possible workaround could be replacing it with something like this:

Le.defaultProps={offset:10,container:typeof window==='undefined'?{}:window}

Hope it helps!


cariforef priority commented 2 years ago

Hi jlopez994,

It works !! thanks a lot. Didier



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Priority
  • Premium support: Yes
  • Technology: MDB React
  • MDB Version: MDB5 4.0.0
  • Device: macbook
  • Browser: Chrome
  • OS: Mac OS
  • Provided sample code: No
  • Provided link: No