JSFiddle - React, Tailwind, and code Playground

HTML

<textarea class='autoExpand' rows='2' data-min-rows='2' placeholder='Auto-Expanding Textarea'></textarea>

<textarea class='autoExpand' rows='2' data-min-rows='2' placeholder='Auto-Expanding Textarea'></textarea>

<textarea class='autoExpand' rows='2' data-min-rows='2' placeholder='Auto-Expanding Textarea'></textarea>

CSS

body{ background:#728EB2; }

textarea{  
  display:block;
  box-sizing: padding-box;
  overflow:hidden;

  padding:10px;
  width:250px;
  font-size:14px;
  margin:50px auto;
  border-radius:8px;
  border:6px solid #556677;
}

JavaScript

$(document)
		.one('focus.textarea', '.autoExpand', function(){
			var savedValue = this.value;
			this.value = '';
			this.baseScrollHeight = this.scrollHeight;
			this.value = savedValue;
		})
		.on('input.textarea', '.autoExpand', function(){
			var minRows = this.getAttribute('data-min-rows')|0,
				 rows;
			this.rows = minRows;
        console.log(this.scrollHeight , this.baseScrollHeight);
			rows = Math.ceil((this.scrollHeight - this.baseScrollHeight) / 17);
			this.rows = minRows + rows;
		});