JSFiddle - React, Tailwind, and code Playground

HTML

<canvas id="myCanvas"></canvas>

JavaScript

var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");

var W = 400, H = 400;
canvas.width = W;
canvas.height = H;

function fncBackground(){
    ctx.fillStyle = "#151515";
    ctx.fillRect(0,0,W,H);
}

var pixel = { 
    X: 50,
    Y: 50,
    width: 10,
    height: 10,
    draw: function(){
        ctx.fillStyle = "#2c57e5";
        ctx.fillRect(this.X,this.Y,this.width,this.height);
    }
}

function fncPixelMove(){
    pixel.X++;
}

function fncUpdate(){
fncBackground();
pixel.draw();
fncPixelMove();
}

setInterval(fncUpdate, 10);