JSFiddle - React, Tailwind, and code Playground
HTML
<textarea></textarea>
JavaScript
$('textarea').bind('keyup change', function() {
var $this = $(this), $offset = this.offsetHeight;
$offset > $this.height() && $offset < 300 ?
$this.css('height ', $offset)
.attr('rows', $this.val().split('\n').length)
.css({'height' : $this.attr('scrollHeight'),'overflow' : 'hidden'}) :
$this.css('overflow','auto');
});