You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using react-leaflet with gatsby, a static site generation framework. As long as I'm in development mode everything is ok, but as soon as I try to generate the static bundle webpack reports the following error:
Generating HTML failed Error: ReferenceError: window is not defined
at Object.defineProperty.value (render-page.js:78978:4)
at __webpack_require__ (render-page.js:30:30)
at Object.L.version (render-page.js:65715:17)
at __webpack_require__ (render-page.js:30:30)
at Object.defineProperty.value (render-page.js:65665:17)
at __webpack_require__ (render-page.js:30:30)
at Object.defineProperty.value (render-page.js:65519:15)
at __webpack_require__ (render-page.js:30:30)
at Object.exports.__esModule (render-page.js:51672:22)
at __webpack_require__ (render-page.js:30:30)
Please make sure to check the following boxes before submitting an issue. Thanks!
I'm using react-leaflet with gatsby, a static site generation framework. As long as I'm in development mode everything is ok, but as soon as I try to generate the static bundle webpack reports the following error:
looks like this happens when you import leaflet
https://github.com/PaulLeCam/react-leaflet/blob/master/src/Map.js#L3
according to the react docs
using window is only allowed in componentDidMount() : "Initialization that requires DOM nodes should go here. "
Others seem to have the same problem:
webpack/react-starter#37
gatsbyjs/gatsby#309
and solved it by using
require
instead ofimport
and doing this conditionally...What do you think?
Thanks
Ognian
The text was updated successfully, but these errors were encountered: