perf(ui): memoize derived validation and list computations

The TUN dialog re-split its route-exclusion list, the rule provider
dialog re-sorted its entries and the group-delays hook re-stringified
its group key on every render; each now recomputes only when its input
identity changes. The provider-button hunk re-indents its JSX block
because the sorted entries moved out of the render expression.
This commit is contained in:
Tunglies
2026-11-19 23:16:33 +08:00
parent a85566a2cb
commit 7074cc5c25
3 changed files with 119 additions and 115 deletions
+4 -3
View File
@@ -9,7 +9,7 @@ import {
} from '@mui/material'
import { useLockFn } from 'ahooks'
import type { Ref } from 'react'
import { useState } from 'react'
import { useMemo, useState } from 'react'
import { useTranslation } from 'react-i18next'
import {
@@ -58,8 +58,9 @@ export function TunViewer({ ref }: { ref?: Ref<DialogRef> }) {
dnsMode: '',
})
const routeExcludeAddressItems = splitRouteExcludeAddress(
values.routeExcludeAddress,
const routeExcludeAddressItems = useMemo(
() => splitRouteExcludeAddress(values.routeExcludeAddress),
[values.routeExcludeAddress],
)
const routeExcludeAddressError =
values.autoRoute &&