Skip to content

fix(proxy-pool): 修复代理池页 React #310 渲染异常 - #59

Merged
GOXF merged 1 commit into
goxf/portablefrom
goxf/fix-proxy-pool-hooks
Dec 3, 2026
Merged

GOXF merged 1 commit into
goxf/portablefrom
goxf/fix-proxy-pool-hooks

Conversation

@GOXF

@GOXF GOXF commented Dec 3, 2026

Copy link
Copy Markdown
Owner

负责:Hark/proxyfix · 完成 2026-12-03 11:25 北京

现象

设置 → 代理池页面经常整页变成「管理控制台渲染异常 · Minified React error #310」。

原因

ProxyPoolSection.tsx 在 if (!active) return null 之后还调用了 4 个 hook(2 个 useState、useAutoRuleSummary、useRef)。切到/切离代理池页时 active 变化,两次渲染 hook 数量不同,React 抛 #310。引入于 #43(1085c2d)。

改动

  • 把这 4 个 hook 挪到提前 return 之前,其余逻辑不变。
  • 新增 src/renderer/src/hooksOrder.test.ts:扫描 renderer 全部 .tsx 组件,凡在提前 if (...) return 之后调用 hook 的都报出来,防止再犯。全仓库目前只有这一处。

验证(云电脑,2026-12-03 北京)

  • npx vitest run src/renderer/src/hooksOrder.test.ts:通过,退出码 0
  • 反证:撤回修复后同一测试变红,报出 ProxyPoolSection.tsx:162/163/164/168
  • npm run typecheck:退出码 0
  • npx vitest run src/renderer src/shared src/preload:84 个文件 587 个测试通过,退出码 0
  • npx electron-vite build:退出码 0
  • 未做:真机点开代理池页验证(等出测试版后)。src/main 与 src/adapters 段未跑(本 PR 未改动)。

@GOXF
GOXF merged commit dbe74c1 into goxf/portable Dec 3, 2026
2 checks passed
@GOXF
GOXF deleted the goxf/fix-proxy-pool-hooks branch December 3, 2026 03:19
GOXF added a commit that referenced this pull request Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant