Check out example codes for "input width autosize". It will help you in understanding the concepts better.

Code Example 1

<input 	id="txt" 
		type="text" 
        onkeypress="this.style.width = (this.value.length + 1) + 'em';">

Learn ReactJs, React Native from akashmittal.com