Recipe
Every time user inputs text changes:
- initially sets the height of the textarea to
MIN_HEIGHT
- then sets the height based on the scroll height of the textarea to ensure that the textarea grows with the content
- If the scroll height exceeds
MAX_HEIGHT
pixels, it sets the height of the textarea to MAX_HEIGHT
pixels
Code
JSX:
CSS: