JSFiddle - React, Tailwind, and code Playground

HTML

<canvas width="600" height="100"></canvas>

<footer><p>
Versión con <code>requestAnimationFrame</code> 💅🏼
</p></footer>

CSS

canvas {
  background: #000;
}

JavaScript

var canvas = document.querySelector('canvas');
var ctx = canvas.getContext('2d');

var x = 0;

function render() {
	ctx.clearRect(0, 0, canvas.width, canvas.height);
	ctx.fillStyle = '#00E436';
	ctx.fillRect(x, 25, 50, 50);
  x = (x + 1) % canvas.width;
  
  requestAnimationFrame(render);
}

requestAnimationFrame(render);