Repository navigation
fix(wujie-react): 修复 React StrictMode 下子应用不启动的问题 - #1119
Merged
Merged
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
This was referenced Nov 13, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
wujie-react目前没有单测基础设施,本次以真实浏览器复现验证详细描述
wujie-react@2.1.0在 React 18<StrictMode>(开发模式)下不会启动子应用,容器一直空白。2.0.2正常。#1098 给组件加了
isUnmounted,在componentWillUnmount置为true,用来拦住卸载后残留在__WUJIE_QUEUE里的startApp。StrictMode 会在同一个实例上执行 挂载 → 卸载 → 再挂载,再挂载时标志没有被重置,execStartApp直接返回:修复:
componentDidMount开头把isUnmounted重置为false。false,行为不变。true,fix: 修复子应用刷新场景 destroy 竞态导致的内存泄漏 #1098 要拦的残留调用照样被拦住。Vue 2 / Vue 3 封装不会复用实例重新挂载,不受影响,未修改。
验证
React 18.3.1 + Chromium 127,子应用 HTML 延迟 500ms,每 50ms 采样容器内容:
wujie-app待验证:React 19.2
<Activity>隐藏再显示时可能同样在同一实例上卸载再挂载,本 PR 应同样覆盖,但未实测。关联:#1111(该 issue 是直接调用
wujie-core的startApp时的并发问题,与本 PR 不同;本 PR 保证改用wujie-react封装组件后 StrictMode 可用)另外发现(不在本 PR 范围)
加载中卸载组件时,
startApp会抛出「此报错可以忽略,iframe主动中断主应用代码在子应用运行」(#54),被组件的try/catch吞掉,this.destroy拿不到,兜底销毁不执行,卸载后仍残留 1 个 sandbox iframe。master 上即如此,与本 PR 无关,另行跟进。Made with Cursor