appleple / react-modal-video

Accessible React Modal Video Component
https://appleple.github.io/react-modal-video/
MIT License
177 stars 86 forks source link

Can't get the modal view to show in Gatsby; I get the window is not defined error. #77

Closed Djotchuang closed 2 years ago

Djotchuang commented 2 years ago

I'm not able to make the modal to show in Gatsby 2.24.64. I get the window is not defined error. I saw that this problem can be solved in Nextjs using the dynamic library, but there isn't a library like that for gatsby. Could someone help me out, please?

I used the code outlined here https://appleple.github.io/react-modal-video/ using react hooks.

stevengrimaldo commented 2 years ago

It's also an issue in the latest version of Gatsby as well, 4.6.0.

Djotchuang commented 2 years ago

Alright, @stevengrimaldo. Did you find any solutions for the issue?

stevengrimaldo commented 2 years ago

@Djotchuang I did! Unfortunately the solution that worked for me that I found after lots of googling was to hard set the version to 1.2.6 in your package.json file.

...
"react-modal-video": "1.2.6",
...
Djotchuang commented 2 years ago

Thanks so much, @stevengrimaldo it worked! What I did was delete the line in package.json and package-lock.json and run npm install react-modal-video@1.2.6; I still had the error. Then, I reran gatsby develop and it worked. Thanks again!

Djotchuang commented 2 years ago

The solution is to revert to react-modal-video v1.2.6, which works fine with Gatsby.

JonathanLehner commented 2 years ago

v1.2.6 works for me too. this is ridiculous... the latest release should work properly