JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://rawgit.com/tsayen/dom-to-image/master/src/dom-to-image.js"></script>
<div id="div"></div>
<img id="img">
CSS
div {
width: 250px;
height: 200px;
background: url(https://raw.githubusercontent.com/tsayen/dom-to-image/master/spec/resources/images/image.jpeg) no-repeat;
background-size: 100% 100%;
}
JavaScript
var image = document.getElementById('img');
var node = document.getElementById('div');
domtoimage.toPng(node).then(function (pngDataUrl) {
image.src = pngDataUrl;
});