Using Gatsby js : WebpackError: window is not defined
ruslan-mystore opened this issue · comments
When using redux-zero in the 'development' mode everything is fine.
When using redux-zero without actions, the build is working also fine.
But when i'm using actions and trying to use 'build', i'm getting this error:
67 | return result;
68 | }; }; };
> 69 | if (window !== undefined && window.__REDUX_DEVTOOLS_EXTENSION__) {
| ^
70 | exports.connect = function (initialState) {
71 | devTools.instance = window.__REDUX_DEVTOOLS_EXTENSION__.connect();
72 | devTools.instance.send("initialState", initialState);
WebpackError: window is not defined
- index.js:69 Object.exports.replaceRenderer
~/redux-zero/devtools/index.js:69:1
- createStore.js:6 Object.assign.i
src/store/createStore.js:6:1
- gatsby-ssr.js:4 Object.defineProperty.value
gatsby-ssr.js:4:1
- api-runner-ssr.js:11 Object.<anonymous>
.cache/api-runner-ssr.js:11:15
- static-entry.js:6 Object.<anonymous>
.cache/static-entry.js:6:1
Are you using the Redux Zero's devtools?
@matheusml Yes, from the example in the repository
@ruslan-mystore it's probably and SSR issue.
Could you send a PR changing this:
if (window !== undefined && window.__REDUX_DEVTOOLS_EXTENSION__) {
to this:
if (typeof window === "object" && window.__REDUX_DEVTOOLS_EXTENSION__) {
That's probably going to fix it.
Same error:
67 | return result;
68 | }; }; };
> 69 | if (typeof window !== undefined && window.__REDUX_DEVTOOLS_EXTENSION__) {
| ^
70 | exports.connect = function (initialState) {
71 | devTools.instance = window.__REDUX_DEVTOOLS_EXTENSION__.connect();
72 | devTools.instance.send("initialState", initialState);
@ruslan-mystore please update redux-zero
to version 4.13.1
and try again.
@matheusml Thanks, that working just fine.
I will add gatsby redux-zero starter to gatsby site:
https://www.gatsbyjs.org/docs/gatsby-starters/
Thanks for that @ruslan-mystore! 👍