JSFiddle - React, Tailwind, and code Playground

by Trung Đinh Quang

HTML

<div id="box">
</div>

CSS

#box {
  left: 0;
  top: 0;
  transition: left 0.5s, top 0.5s;
  position: absolute;
  width: 50px;
  height: 50px;
  background-color: gray;
}

#box.active {
  left: 100px;
  top: 100px;
}

Babel + JSX

setInterval(() => {
	if (box.classList.contains('active')) {
	  box.classList.remove('active');
  } else {
    box.classList.add('active');
  }
}, 1000)