import React, { useCallback, useRef } from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import { Button, Checkbox, Icon } from 'semantic-ui-react'; import NameEdit from './NameEdit'; import ActionsPopup from './ActionsPopup'; import styles from './Item.module.scss'; const Item = React.memo(({ name, isCompleted, isPersisted, canEdit, onUpdate, onDelete }) => { const nameEdit = useRef(null); const handleClick = useCallback(() => { if (isPersisted && canEdit) { nameEdit.current.open(); } }, [isPersisted, canEdit]); const handleNameUpdate = useCallback( (newName) => { onUpdate({ name: newName, }); }, [onUpdate], ); const handleToggleChange = useCallback(() => { onUpdate({ isCompleted: !isCompleted, }); }, [isCompleted, onUpdate]); const handleNameEdit = useCallback(() => { nameEdit.current.open(); }, []); return (