import React, { useLayoutEffect, useRef } from "react"; const EditElement = (props) => { const { className, handleEditValue, value, setShowInputEle, showInputEle, handleFocus, handleBlur, i, } = props; const MIN_TEXTAREA_HEIGHT = 32; const textareaRef = useRef(null); useLayoutEffect(() => { // Reset height to shrink on delete textareaRef.current.style.height = "inherit"; // Set height textareaRef.current.style.height = `${Math.max( textareaRef.current.scrollHeight, MIN_TEXTAREA_HEIGHT )}px`; }, [value]); return (