I am trying to add the auto resize feature on textarea. The code below works well only if I type something. However, if I just updates value which is from api, it does not trigger any event. Therefore, it cannot be resize. Is there anyway I can trigger keyup or other event to trigger function to get scrollHeight programatically??
autoResizeTextArea = (e) => {
const element = e.target
element.style.height = 'auto'
element.style.overflowY = 'hidden'
element.style.height = element.scrollHeight + 'px'
}