I currently have a canvas barcode generated by the react implementation of JsBarcode called react-barcode. Currently, I am able to right-click the canvas and open it as an image in a new tab. How do I implement this functionality with a click of a button instead?
I have already checked several answers to this problem but all of them use jquery. I am looking for implementation with React or pure js.
Use HTMLCanvasElement#toDataURL
I think that SO blocks window.open, but simply copy the console logged data and paste it in a new tab.