JSFiddle - React, Tailwind, and code Playground
HTML
<a>
<canvas width="300" height="300" id="canvas"></canvas>
</a>
JavaScript
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#ff5';
ctx.fillRect(0, 0, canvas.width, canvas.height);
$('#canvas').click(function(){
$(this).parent().attr('href', document.getElementById('canvas').toDataURL());
$(this).parent().attr('download', "myPicture.png");
});