title: React useRef is undefined
body: <p>I think I may be misusing <code>useRef</code> here. When I try to draw to the canvas I am getting the following error: <code>cannot set 'fillStyle' of undefined</code>.</p>
  
  <pre><code>import React, { useEffect, useRef } from "react";
  import useWindowSize from "../hooks/useWindowSize";
  
  export default function Player() {
    const canvasRef = useRef();
    const ctx = useRef();
  
    useEffect(() =&gt; {
      ctx.current = canvasRef.current.getContext("2d");
    }, []);
    ctx.current.fillStyle = "green";
    ctx.current.fillRect(20, 20, 150, 100);
    return (
      &lt;React.Fragment&gt;
        &lt;div&gt;Hello&lt;/div&gt;
        &lt;canvas ref={canvasRef} width="500" height="500" /&gt;
      &lt;/React.Fragment&gt;
    );
  }
  
  </code></pre>