JSFiddle - React, Tailwind, and code Playground

HTML

<textarea placeholder="Type with newlines">
Hello
this
is
text
</textarea>
<div></div>

JavaScript

document.querySelector("textarea").addEventListener("keyup", function () {
    document.querySelector("div").innerHTML = this.value.replace(/\n/g, "<br />");
});