JSFiddle - React, Tailwind, and code Playground
HTML
<canvas id="file-preview" width="300" height="300"></canvas>
JavaScript
var img = new Image;
img.src = "http://cdn.bmwblog.com/wp-content/uploads/2016/02/M-Performance-Parts-BMW-M2-3.jpg";
var c= document.getElementById('file-preview');
var ctx=c.getContext("2d");
img.onload = function(){
ctx.drawImage(img, img.width/2, img.height/2, img.width, img.height,0, 0, img.width, img.height);
};