Skip to content

Commit

Permalink
fix(taro-plugin-react): 修复3.5小程序中app不会触发首次componentDidShow系列生命周期
Browse files Browse the repository at this point in the history
  • Loading branch information
Barrierml authored and Chen-jj committed Oct 16, 2022
1 parent ddbf773 commit 49dab3b
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions packages/taro-plugin-react/src/runtime/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,22 @@ export function createReactApp (
value (options) {
setRouterParams(options)

/**
* trigger lifecycle
*/
const app = getAppInstance()
// class component, componentDidShow
app?.componentDidShow?.(options)
// functional component, useDidShow
triggerAppHook('onShow', options)
const onShow = () => {
/**
* trigger lifecycle
*/
const app = getAppInstance()
// class component, componentDidShow
app?.componentDidShow?.(options)
// functional component, useDidShow
triggerAppHook('onShow', options)
}

if (appWrapper) {
onShow()
} else {
appWrapperPromise.then(onShow)
}
}
}),

Expand Down

0 comments on commit 49dab3b

Please sign in to comment.