import React, { useEffect, useRef } from 'react' type Props = React.TextareaHTMLAttributes & { value: string; onChange: (e: React.ChangeEvent) => void } export default function AutoTextarea(props: Props){ const ref = useRef(null) const resize=()=>{ const el=ref.current; if(!el) return; el.style.height='0px'; el.style.height=el.scrollHeight+'px' } useEffect(()=>{ resize() },[props.value]) return