title: Issue with window object on a functional react component
body: <p>I need to access the <code>window</code> object in my react component to get something from the query string. This is what my component looks like:</p>
  
  <pre><code>export function MyComponent() {
    return (
      &lt;div&gt;
        Display the qs: {(window &amp;&amp; window.location.search) || 'nothing'}
      &lt;/div&gt;
    )
  }
  </code></pre>
  
  <p>This is all fine and well if I run the app and then visit the page where I need to access the window, but if I start the app on the page I need the window, I get the following error:</p>
  
  <blockquote>
    <p>ReferenceError: window is not defined</p>
  </blockquote>
  
  <p>Most the solutions I see so far make use of the <code>componentWillMount</code> to solve the issue. So my question is, how do I solve this issue in the functional component? Or what is the best way to do so without using the lifecycle methods?</p>
  
  <p>Not sure if this is relevant but I am using NextJS as well.</p>