title: I had an issue today with window.addEventListener and React Native
body: <p>I was trying to implement dynamic re-rendering of my react application using this function I found here:
  <a href="https://stackoverflow.com/a/19014495/7838374">https://stackoverflow.com/a/19014495/7838374</a></p>
  <pre><code>function useWindowSize() {
    const [size, setSize] = useState([0, 0]);
    useLayoutEffect(
      () =&gt; {
        function updateSize() {
          setSize([window.innerWidth, window.innerHeight]);
        }
        window.addEventListener(&quot;resize&quot;, updateSize);
        updateSize();
        return () =&gt; window.removeEventListener(&quot;resize&quot;, updateSize);
      },[]);
    return size;
  }
  
  function ShowWindowDimensions(props) {
    const [width, height] = useWindowSize();
    return (
      &lt;span&gt;
        Window size: {width} x {height}
      &lt;/span&gt;
    );
  }
  </code></pre>
  <p>Link to my app:
  <a href="https://github.com/Intetra/aubreyw" rel="nofollow noreferrer">https://github.com/Intetra/aubreyw</a></p>
  <p>I was able to get everything working perfectly when displaying my app in the browser on my desktop. I'm using expo to run the app. The problem came when I tried to run the app on my android phone. I was getting an error at launch.</p>
  <p><strong>COMPONENT EXCEPTION: window.addEventListener is not a function</strong></p>
  <p>I was able to get it working with a solution I found here:
  <a href="https://stackoverflow.com/a/61470685/7838374">https://stackoverflow.com/a/61470685/7838374</a></p>
  <p>That solution says that the event listener for window doesn't exist in react native, so we have to mock it. I don't understand what that means. I still don't know why the solution I found worked. I would like to understand. Can someone enlighten me?</p>