roseline124/wannabe_gatsby

#1 fix 'window is not defined' error in serverside rendering

roseline124 opened this issue · 1 comments

Problem description

  • cannot access 'window' in server side when building gatsby

Causes of this problem

Kyle said:
during development, react components are only run in the browser where window is defined. When building, Gatsby renders these components on the server where window is not defined


Solutions

  • access window in componentDidMount
  • check that window exists before accessing it

another error(following above error) : Building static HTML failed for path "/hello-world/"