I'm trying to solve Error: jQuery requires a window with a document #16433
-
Error I'm getting - I'm trying to import var $ = require('jquery')(require("jsdom").jsdom().parentWindow); or var $ = require('jquery')(require("jsdom").JSDOM().window); my code where I'm using this functionality
Guy's please help me to out from this situation |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You could use
|
Beta Was this translation helpful? Give feedback.
You could use
next/dynamic
withssr: false
to import the component that uses jQuery (orwindow
). https://nextjs.org/docs/advanced-features/dynamic-import#with-no-ssrnext/dynamic
only works with React components, so you can put your logic within a component and then usessr: false
when you import that component.