'How to convert canvas stage to save in png/jpeg react konva

  function downloadURI(uri, name) {
       var link = document.createElement('a');
       link.download = name;
       link.href = uri;
       document.body.appendChild(link);
       link.click();
       document.body.removeChild(link);
       delete link;
     }

     document.getElementById('save').addEventListener(
       'click',
       function () {
         var dataURL = stage.toDataURL({ pixelRatio: 3 });
         downloadURI(dataURL, 'stage.png');
       },
       false
     );

this is being implemented for html5 but i want to how it can be implemented in react please help i have been stuck on this for days



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source