Skip to content

Commit 925c222

Browse files
committed
fix: 修复输出RN组件销毁后导致rpx/vw/vh相应式单位失效
fix: 修复组件销毁后导致rpx/vw/vh相应式单位失效
1 parent 0c71f25 commit 925c222

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/core/src/platform/patch/getDefaultOptions.ios.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ const triggerResizeEvent = (mpxProxy, sizeRef) => {
398398
}
399399
}
400400

401-
function usePageEffect (mpxProxy, pageId) {
401+
function usePageEffect (mpxProxy, pageId, type) {
402402
const sizeRef = useRef(getSystemInfo())
403403

404404
useEffect(() => {
@@ -415,7 +415,7 @@ function usePageEffect (mpxProxy, pageId) {
415415
triggerResizeEvent(mpxProxy, sizeRef)
416416

417417
// 如果当前全局size与pagesize不一致,在show之后触发一次resize事件
418-
if (newVal === 'show' && global.__mpxPageSizeCountMap[pageId] !== global.__mpxSizeCount) {
418+
if (type === 'page' && newVal === 'show' && global.__mpxPageSizeCountMap[pageId] !== global.__mpxSizeCount) {
419419
// 刷新__mpxPageSizeCountMap, 每个页面仅会执行一次,直接驱动render刷新
420420
global.__mpxPageSizeCountMap[pageId] = global.__mpxSizeCount
421421
}
@@ -427,7 +427,9 @@ function usePageEffect (mpxProxy, pageId) {
427427
}
428428
return () => {
429429
unWatch && unWatch()
430-
del(global.__mpxPageSizeCountMap, pageId)
430+
if (type === 'page') {
431+
del(global.__mpxPageSizeCountMap, pageId)
432+
}
431433
}
432434
}, [])
433435
}
@@ -697,7 +699,7 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
697699
}
698700
})
699701

700-
usePageEffect(proxy, pageId)
702+
usePageEffect(proxy, pageId, type)
701703
useEffect(() => {
702704
proxy.mounted()
703705
return () => {

0 commit comments

Comments
 (0)