JSFiddle - React, Tailwind, and code Playground

HTML

<div id="foo">test</div>

JavaScript

$('#foo').fadeOut("slow", function(){
   var div = $("<div id='foo'>test2</div>").hide();
   $(this).replaceWith(div);
   $('#foo').fadeIn("slow");
});