import React from "react"; interface Props { closeRemapFunction: () => void; renameCallback: (file: any, newName: string) => void; file: any; } const Rename = (props: Props) => { const { closeRemapFunction, file, renameCallback } = props; const [newName, setNewName] = React.useState(file.attributes.name); const handleKeyDown = (event: React.KeyboardEvent) => { if (event.key === "Escape") { console.log("esc"); closeRemapFunction(); } else if (event.key === "Enter") { console.log("enter pressed"); } }; const handleRename = (event: React.MouseEvent) => { // use from parent function named putRenameFile // renameFunction(file, newName); renameCallback(file, newName); }; const ref = React.useRef(null); React.useEffect(() => { if (ref.current) { ref.current.focus(); } }, []); return (
setNewName(e.target.value)} />
); }; export default Rename;