title: Exclude element when download with dom-to-image library
body: <p>I am using <a href="https://github.com/tsayen/dom-to-image" rel="nofollow noreferrer">dom-to-image</a> library to download component as a png image. However I want some elements to be excluded from downloaded image like a close button, etc</p>
  
  <p>I tried with this approach, to set visible true/false and to hide it with CSS:</p>
  
  <pre><code>const [visible, setVisible] = React.useState(true);
  
      const closeClassName = classNames(classes.visible, {
          [classes.hidden]: visible === false,
      });
  
      const downloadTemperaturesGraph = React.useCallback(() =&gt; {
          if (chartRef.current) {
              setVisible(false);
              domtoimage.toBlob(chartRef.current, { bgcolor: 'white' }).then((blob) =&gt; {
                  fileDownload(blob, `${title}.png`);
              });
  
              setTimeout(() =&gt; {
                  setVisible(true);
              });
          }
      }, [chartRef, title]);
  </code></pre>
  
  <p>Is there any better way to do it? Could this be done with library's filter option?</p>