Skip to content

Commit

Permalink
fix: 修复插件中调用 Taro 挂载 api 出错的问题,close #9587
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyadam authored and Chen-jj committed Aug 11, 2021
1 parent a297bd9 commit c4169aa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/taro-loader/src/native-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ if (typeof PRERENDER !== 'undefined') {
}`

return `${setReconciler}
import { createNativeComponentConfig } from '@tarojs/runtime'
import component from ${stringify(componentPath)}
import { defaultReconciler } from '@tarojs/shared'
import { createNativeComponentConfig, container, SERVICE_IDENTIFIER } from '@tarojs/runtime'
${importFrameworkStatement}
var hooks = container.get(SERVICE_IDENTIFIER.Hooks)
hooks.initNativeApiImpls = [defaultReconciler.initNativeApi]
var component = require(${stringify(componentPath)}).default
var config = ${configString};
var inst = Component(createNativeComponentConfig(component, ${frameworkArgs}))
${options.prerender ? prerender : ''}
Expand Down
2 changes: 2 additions & 0 deletions packages/taro-runtime/src/dsl/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,8 @@ export function createNativeComponentConfig (Component, react: typeof React, rea
R = react
ReactDOM = reactdom

setReconciler()

const config = {
properties: {
props: {
Expand Down
1 change: 1 addition & 0 deletions packages/taro-runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export { createDocument, document } from './bom/document'
export { window } from './bom/window'
export { navigator } from './bom/navigator'
export { default as container } from './container'
export { default as processPluginHooks } from './container/plugin-hooks'
export { default as SERVICE_IDENTIFIER } from './constants/identifiers'
export { connectReactPage, createReactApp, createNativeComponentConfig } from './dsl/react'
export { connectVuePage, createVueApp } from './dsl/vue'
Expand Down

0 comments on commit c4169aa

Please sign in to comment.