diff --git a/src/renderer/src/components/browser-pane/BrowserToolbarMenu.tsx b/src/renderer/src/components/browser-pane/BrowserToolbarMenu.tsx index e3d6da35693..95b004f4aaa 100644 --- a/src/renderer/src/components/browser-pane/BrowserToolbarMenu.tsx +++ b/src/renderer/src/components/browser-pane/BrowserToolbarMenu.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef, useState } from 'react' +import { useState } from 'react' import { Check, Ellipsis, Import, Monitor, Plus, Settings } from 'lucide-react' import { toast } from 'sonner' import { Button } from '@/components/ui/button' @@ -25,6 +25,7 @@ import { DropdownMenuTrigger } from '@/components/ui/dropdown-menu' import { useAppStore } from '@/store' +import { useMountedRef } from '@/hooks/useMountedRef' import { BROWSER_FAMILY_LABELS } from '../../../../shared/constants' import type { BrowserViewportPresetId } from '../../../../shared/types' import { @@ -71,7 +72,7 @@ export function BrowserToolbarMenu({ const [pendingSwitchProfileId, setPendingSwitchProfileId] = useState( undefined ) - const mountedRef = useRef(true) + const mountedRef = useMountedRef() const effectiveProfileId = currentProfileId ?? 'default' @@ -82,13 +83,6 @@ export function BrowserToolbarMenu({ ? [defaultProfile, ...browserSessionProfiles.filter((p) => p.id !== 'default')] : browserSessionProfiles - useEffect(() => { - mountedRef.current = true - return () => { - mountedRef.current = false - } - }, []) - const handleSwitchProfile = (profileId: string | null): void => { const targetId = profileId ?? 'default' if (targetId === effectiveProfileId) {