JSFiddle - React, Tailwind, and code Playground
HTML
<div contenteditable="true" id="divTest" style="border: 1px solid red"></div>
<input type="button" value="Hide the div and look at the console ..." onclick="experiment()"/>
JavaScript
function experiment() {
let divTest = document.getElementById("divTest")
// show the content
console.log(divTest.innerText)
// hide the div
divTest.style.display = 'none'
// check the content : the new lines are gone
console.log(divTest.innerText)
}