import PropTypes from 'prop-types' import React, { useRef, useState } from 'react' import { Button, TextInput } from '@patternfly/react-core' import { PencilAltIcon, CheckIcon, TimesIcon } from '@patternfly/react-icons' function NameComponent({ name, onEdit }) { const [isEditing, setEditing] = useState(false) const nameInput = useRef(null) const onCancel = () => { nameInput.current.value = name setEditing(false) } const onSubmit = (event) => { if (event) { event.preventDefault() } const name = nameInput.current.value if (name) { onEdit(name) } setEditing(false) } return (
{name}
) } NameComponent.propTypes = { name: PropTypes.string, onEdit: PropTypes.func, } export default NameComponent