@@ -33,7 +33,7 @@ function getSystemInfo () {
3333 }
3434}
3535
36- function createEffect ( proxy , components ) {
36+ function createEffect ( proxy , componentsMap ) {
3737 const update = proxy . update = ( ) => {
3838 // react update props in child render(async), do not need exec pre render
3939 // if (proxy.propsUpdatedFlag) {
@@ -50,10 +50,11 @@ function createEffect (proxy, components) {
5050 const getComponent = ( tagName ) => {
5151 if ( ! tagName ) return null
5252 if ( tagName === 'block' ) return Fragment
53- const appComponents = global . __getAppComponents ?. ( ) || { }
53+ const appComponentsMap = global . __appComponentsMap || { }
5454 const generichash = proxy . target . generichash || ''
55- const genericComponents = global . __mpxGenericsMap ?. [ generichash ] || noop
56- return components [ tagName ] || genericComponents ( tagName ) || appComponents [ tagName ] || getByPath ( ReactNative , tagName )
55+ const genericComponentsMap = global . __mpxGenericsMap ?. [ generichash ] || { }
56+ const componentGetter = componentsMap [ tagName ] || genericComponentsMap [ tagName ] || appComponentsMap [ tagName ]
57+ return componentGetter ? componentGetter ( ) : getByPath ( ReactNative , tagName )
5758 }
5859 const innerCreateElement = ( type , ...rest ) => {
5960 if ( ! type ) return null
@@ -203,7 +204,7 @@ const instanceProto = {
203204 }
204205}
205206
206- function createInstance ( { propsRef, type, rawOptions, currentInject, validProps, components , pageId, intersectionCtx, relation, parentProvides } ) {
207+ function createInstance ( { propsRef, type, rawOptions, currentInject, validProps, componentsMap , pageId, intersectionCtx, relation, parentProvides } ) {
207208 const instance = Object . create ( instanceProto , {
208209 dataset : {
209210 get ( ) {
@@ -319,7 +320,7 @@ function createInstance ({ propsRef, type, rawOptions, currentInject, validProps
319320 stateVersion : Symbol ( ) ,
320321 subscribe : ( onStoreChange ) => {
321322 if ( ! proxy . effect ) {
322- createEffect ( proxy , components )
323+ createEffect ( proxy , componentsMap )
323324 proxy . stateVersion = Symbol ( )
324325 }
325326 proxy . onStoreChange = onStoreChange
@@ -335,7 +336,7 @@ function createInstance ({ propsRef, type, rawOptions, currentInject, validProps
335336 } )
336337 // react数据响应组件更新管理器
337338 if ( ! proxy . effect ) {
338- createEffect ( proxy , components )
339+ createEffect ( proxy , componentsMap )
339340 }
340341
341342 return instance
@@ -571,7 +572,12 @@ export function PageWrapperHOC (WrappedComponent, pageConfig = {}) {
571572}
572573export function getDefaultOptions ( { type, rawOptions = { } , currentInject } ) {
573574 rawOptions = mergeOptions ( rawOptions , type , false )
574- const components = Object . assign ( { } , rawOptions . components , currentInject . getComponents ( ) )
575+ const componentsMap = currentInject . componentsMap
576+ if ( rawOptions . components ) {
577+ Object . entries ( rawOptions . components ) . forEach ( ( [ key , item ] ) => {
578+ componentsMap [ key ] = ( ) => item
579+ } )
580+ }
575581 const validProps = Object . assign ( { } , rawOptions . props , rawOptions . properties )
576582 const { hasDescendantRelation, hasAncestorRelation } = checkRelation ( rawOptions )
577583 if ( rawOptions . methods ) rawOptions . methods = wrapMethodsWithErrorHandling ( rawOptions . methods )
@@ -589,7 +595,7 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
589595 let isFirst = false
590596 if ( ! instanceRef . current ) {
591597 isFirst = true
592- instanceRef . current = createInstance ( { propsRef, type, rawOptions, currentInject, validProps, components , pageId, intersectionCtx, relation, parentProvides } )
598+ instanceRef . current = createInstance ( { propsRef, type, rawOptions, currentInject, validProps, componentsMap , pageId, intersectionCtx, relation, parentProvides } )
593599 }
594600 const instance = instanceRef . current
595601 useImperativeHandle ( ref , ( ) => {
0 commit comments