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 (
{showInputEle ? (
handleBlur(e, i)} tabIndex="0" >
) : (
handleFocus("plain-div onCLick, i", i)} onBlur={(e) => handleBlur(e, i)} className="outer-div" tabIndex="0" >