From 49dab3b2f2e6ed2a5d4c4a24a6d61f1ca5a24b7c Mon Sep 17 00:00:00 2001 From: SHIROHA <1196768261@qq.com> Date: Sun, 16 Oct 2022 14:06:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(taro-plugin-react):=20=E4=BF=AE=E5=A4=8D3.5?= =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E4=B8=ADapp=E4=B8=8D=E4=BC=9A?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E9=A6=96=E6=AC=A1componentDidShow=E7=B3=BB?= =?UTF-8?q?=E5=88=97=E7=94=9F=E5=91=BD=E5=91=A8=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../taro-plugin-react/src/runtime/connect.ts | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/taro-plugin-react/src/runtime/connect.ts b/packages/taro-plugin-react/src/runtime/connect.ts index aebbd6e3172b..123264c96dbb 100644 --- a/packages/taro-plugin-react/src/runtime/connect.ts +++ b/packages/taro-plugin-react/src/runtime/connect.ts @@ -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) + } } }),