JSFiddle - React, Tailwind, and code Playground

CSS

canvas{ background-color:red; }

JavaScript

function createContext(width, height) {
var canvas = document.createElement('canvas');
canvas.id = "1";
canvas.width = width;
canvas.height = height;
document.body.appendChild(canvas);
return canvas.getContext('2d');
}
createContext('100', '100');