title: React.js: useEffect with window resize event listener not working
body: <p>I'm using this code to listen for resize events in a function component and rerender the component when the window is resized. The problem is, nothing ever gets printed out for either event listener, so I think I have a misunderstanding of how I'm using useEffect here.</p>
  <pre><code>  const [dimensions, setDimensions] = React.useState({
      width: window.innerWidth,
      height: window.innerHeight,
    });
  
    useEffect(() =&gt; {
      const handleResize = () =&gt; {
        console.log(dimensions.width);
        setDimensions({
          width: window.innerWidth,
          height: window.innerHeight,
        });
        window.addEventListener(&quot;load&quot;, handleResize, false);
        window.addEventListener(&quot;resize&quot;, handleResize, false);
      };
    });
  </code></pre>