JSFiddle - React, Tailwind, and code Playground

HTML

<textarea id="ta">fdgdsfgsd
af
sdaf
sf

fsa
f
sdf
sadfsadfsafsadf
sa
df
sad
fs
dfsdaf</textarea>

CSS

textarea {
   
    resize:none;
}

JavaScript

$("#ta").keyup(function (e) {
    autoheight(this);
});

function autoheight(a) {
    if (!$(a).prop('scrollTop')) {
        do {
            var b = $(a).prop('scrollHeight');
            var h = $(a).height();
            $(a).height(h - 5);
        }
        while (b && (b != $(a).prop('scrollHeight')));
    };
    $(a).height($(a).prop('scrollHeight') + 20);
}

autoheight($("#ta"));