Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: 修复输出RN externalClasses 变化时未触发组件render
  • Loading branch information
mackwang112 committed Mar 10, 2026
commit 97b32fc3fe02a4cd0c7700e406a8af16b28bfa82
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,9 @@ export default function styleHelperMixin () {
} else if (appStyle = global.__getAppClassStyle?.(className)) {
mergeResult(appStyle._default, getMediaStyle(appStyle._media))
this.__dependentScreenSize = this.__dependentScreenSize || appStyle._dependentScreenSize
} else if (isObject(this.__props[className])) {
} else if (isObject(this.__mpxProxy.props[className])) {
// externalClasses必定以对象形式传递下来
mergeResult(this.__props[className])
mergeResult(this.__mpxProxy.props[className])
}
})
}
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/platform/patch/getDefaultOptions.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,11 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
})
}
const validProps = Object.assign({}, rawOptions.props, rawOptions.properties)
if (global.__externalClasses && global.__externalClasses.length > 0) {
global.__externalClasses.forEach((name) => {
validProps[name] = null
})
}
const { hasDescendantRelation, hasAncestorRelation } = checkRelation(rawOptions)
if (rawOptions.methods) rawOptions.methods = wrapMethodsWithErrorHandling(rawOptions.methods)
const defaultOptions = memo(forwardRef((props, ref) => {
Expand Down
3 changes: 2 additions & 1 deletion packages/webpack-plugin/lib/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = function (content) {
return content
}
const { resourcePath, queryObj } = parseRequest(this.resource)

const externalClasses = mpx.externalClasses || []
const packageRoot = queryObj.packageRoot || mpx.currentPackageRoot
const packageName = packageRoot || 'main'
const independent = queryObj.independent
Expand Down Expand Up @@ -178,6 +178,7 @@ module.exports = function (content) {
originalUsingComponents,
componentGenerics,
autoScope,
externalClasses,
callback
})
}
Expand Down
4 changes: 3 additions & 1 deletion packages/webpack-plugin/lib/react/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = function ({
originalUsingComponents,
componentGenerics,
autoScope,
externalClasses,
callback
}) {
if (ctorType === 'app' && !queryObj.isApp) {
Expand Down Expand Up @@ -95,7 +96,8 @@ module.exports = function ({
wxsModuleMap: templateRes.wxsModuleMap,
localComponentsMap: jsonRes.localComponentsMap,
localPagesMap: jsonRes.localPagesMap,
rnConfig
rnConfig,
externalClasses
}, callback)
}
], (err, scriptRes) => {
Expand Down
5 changes: 3 additions & 2 deletions packages/webpack-plugin/lib/react/processScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ module.exports = function (script, {
localPagesMap,
rnConfig,
componentGenerics,
genericsInfo
genericsInfo,
externalClasses
}, callback) {
const { appInfo, i18n } = loaderContext.getMpx()

Expand Down Expand Up @@ -49,7 +50,7 @@ import { getComponent, getAsyncSuspense } from ${stringifyRequest(loaderContext,
jsonConfig,
rnConfig
})
output += buildGlobalParams({ moduleId, scriptSrcMode, loaderContext, isProduction, ctorType, jsonConfig, componentsMap, pagesMap, firstPage, hasApp })
output += buildGlobalParams({ moduleId, scriptSrcMode, loaderContext, isProduction, ctorType, jsonConfig, componentsMap, pagesMap, firstPage, hasApp, externalClasses })
output += getRequireScript({ ctorType, script, loaderContext })
output += `export default global.__mpxOptionsMap[${JSON.stringify(moduleId)}]\n`
} else {
Expand Down
4 changes: 3 additions & 1 deletion packages/webpack-plugin/lib/react/script-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ function buildGlobalParams ({
firstPage,
outputPath,
genericsInfo,
hasApp
hasApp,
externalClasses
}) {
let content = ''
if (ctorType === 'app') {
Expand All @@ -165,6 +166,7 @@ global.__style = ${JSON.stringify(jsonConfig.style || 'v1')}
global.__mpxPageConfig = ${JSON.stringify(jsonConfig.window)}
global.__appComponentsMap = ${shallowStringify(componentsMap)}
global.__preloadRule = ${JSON.stringify(jsonConfig.preloadRule)}
global.__externalClasses = ${JSON.stringify(externalClasses || [])}
global.currentInject.pagesMap = ${shallowStringify(pagesMap)}
global.currentInject.firstPage = ${JSON.stringify(firstPage)}\n`
} else {
Expand Down