Skip to content

Commit 3d32a6e

Browse files
committed
fix rn invalid var & little fix perf
1 parent d4b0065 commit 3d32a6e

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

  • packages

packages/core/src/core/perf.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ export function wrapAppLifecycleHooks (options) {
3737
if (!__mpx_perf_framework__) return
3838
Object.keys(appLifecycleMeasureNames).forEach((hookName) => {
3939
const hook = options[hookName]
40-
if (typeof hook !== 'function') return
40+
if (typeof hook !== 'function' && hookName !== 'onLaunch') return
4141
options[hookName] = function (...args) {
4242
if (hookName === 'onLaunch') perf.mark('app:onLaunch:start')
43+
if (typeof hook !== 'function') return
4344
const id = perf.scopeStart(appLifecycleMeasureNames[hookName])
4445
const result = hook.apply(this, args)
4546
perf.scopeEnd(id)

packages/webpack-plugin/lib/runtime/components/react/utils.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,6 +1359,11 @@ export function useTransformStyle (styleObj: Record<string, any> = {}, { enableV
13591359
resolvedVarContext = varContextRef.current
13601360
}
13611361
if (varKeyPaths.length) transformVar(normalStyle, varKeyPaths, resolvedVarContext, visitOther)
1362+
} else if (varKeyPaths.length) {
1363+
// 首次渲染未启用 varContext 时,后续新增的 var() 无法正确解析,直接移除避免非法样式透传到 RN 组件。
1364+
varKeyPaths.forEach((varKeyPath) => {
1365+
setStyle(normalStyle, varKeyPath, ({ target, key }) => delete target[key])
1366+
})
13621367
}
13631368

13641369
// apply unocss var

0 commit comments

Comments
 (0)