React

by brigand

HTML

<div id="app"></div>

CSS

.anim {
  animation: c 3s;
}

@keyframes c {
  0% {
    background: black;
  }
  100% {
    background: white;
  }
}

React

function App() {
	const ref = React.useRef();
  
  const refreshAnimation = () => {
  	ref.current.style.animation = 'none'
    requestAnimationFrame(() =>  ref.current.style.animation = '')
  }
  
  return <div className="anim" ref={ref} onClick={refreshAnimation}>
    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quia inventore quo, expedita esse porro, at quaerat atque fugiat sed doloremque blanditiis architecto. Et beatae labore sunt quod dolorem, dolore excepturi.
  </div>
}
ReactDOM.render(<App />, document.querySelector("#app"))