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