title: How to use React.useRef() in class component?
body: <p>I need this code to be implemented in class component.
  It is in order to use a upload progress in my class component with react-toastify</p>
  <pre><code>function Example(){
    const toastId = React.useRef(null);
    function handleUpload(){
      axios.request({
        method: &quot;post&quot;, 
        url: &quot;/foobar&quot;, 
        data: myData, 
        onUploadProgress: p =&gt; {
          const progress = p.loaded / p.total;
          if(toastId.current === null){
              toastId = toast('Upload in Progress', {
              progress: progress
            });
          } else {
            toast.update(toastId.current, {
              progress: progress
            })
          }
        }
      }).then(data =&gt; {
        
        toast.done(toastId.current);
      })
    }
    return (
      &lt;div&gt;
        &lt;button onClick={handleUpload}&gt;Upload something&lt;/button&gt;
      &lt;/div&gt;
    )
  }
  </code></pre>
  <p>How can i do that?</p>