So whenever I compile/run my app, mentioned error pops up, saying "window is not defined", pointing to the function "isMobile" in line 523 of glightbox.js. However, before the function there are some if queries, where window is also used multiple times, seemingly without any problems, so my question now is, what's the deal?
I'm using glightbox via
<script src="./components/js/vendor/glightbox/js/glightbox.min.js"></script>
in the main Header. (/app/Header.js)
My file structure is the following:
app/page_&_header_js
app/components/jsx_files
app/a_sub_page
The culprit:
function isMobile() {
return (
"navigator" in window &&
window.navigator.userAgent.match(
/(iPad)|(iPhone)|(iPod)|(Android)|(PlayBook)|(BB10)|(BlackBerry)|(Opera Mini)|(IEMobile)|(webOS)|(MeeGo)/i
)
);
}
That sounds like whatever framework you're using is trying to run the code on the server, you should see if there is a way to isolate the code to run client only per your framework.
So whenever I compile/run my app, mentioned error pops up, saying "window is not defined", pointing to the function "isMobile" in line 523 of glightbox.js. However, before the function there are some if queries, where window is also used multiple times, seemingly without any problems, so my question now is, what's the deal?
I'm using glightbox via
<script src="./components/js/vendor/glightbox/js/glightbox.min.js"></script>
in the main Header. (/app/Header.js)My file structure is the following: app/page_&_header_js app/components/jsx_files app/a_sub_page
The culprit: