mirror of
https://github.com/stablyai/orca.git
synced 2026-10-14 08:02:56 +00:00
perf: reuse mounted ref in browser toolbar menu
This commit is contained in:
@@ -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<string | null | undefined>(
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user