score:0

Accepted answer
if (itemId) {
  toggleDrawing(itemId);
}

score:1

const toggleDrawing = React.useCallback(async (itemId: string | undefined) => {
    if (isDrawing && editableItemId === itemId) {
        cancelDrawing();
    } else if (isDrawing) {
        cancelDrawing();
        setEditableItemId(itemId);
    } else {
        setEditableWorkAreaId(itemId);
    }
   },[])

Related Query

More Query from same tag