add logic to solve for window not defined error; fix line indents #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some clues and explanations of the error:
Just one of the gotchas of server-side rendering with React.
When Node tries to build, it instantiates the class, and in the constructor finds window, which is a browser global (Node doesn’t have window). gatsbyjs/gatsby#5835
Some of your code references “browser globals” like window or document that aren’t available in Node.js. If this is your problem you should see an error above like “window is not defined”. To fix this, find the offending code and either a) check before calling the code if window is defined so the code doesn’t run while Gatsby is building (see code sample below) or b) if the code is in the render function of a React.js component, move that code into...
https://www.gatsbyjs.com/docs/debugging-html-builds/#how-to-check-if-code-classlanguage-textwindowcode-is-defined
Solution was to wrap our code in an if/else block that checks is window is defined, (which it should be when the code is interpreted in the browser.)
https://bobbyhadz.com/blog/javascript-referenceerror-window-is-not-defined#:~:text=the%20following%20way%3A-,index.js,are%20on%20the%20server%27)%0A%20%20//%20%E2%9B%94%EF%B8%8F%20Don%27t%20use%20window%20here%0A%7D,-We%20check%20if