Skip to content

Commit

Permalink
fix rn mpxAppHotLaunched
Browse files Browse the repository at this point in the history
  • Loading branch information
hiyuki authored and WX-DongXing committed Jan 9, 2025
1 parent be4168c commit fa0b394
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/core/src/platform/createApp.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,16 @@ export default function createApp (options) {
global.__mpxAppLaunched = false
global.__mpxAppHotLaunched = false
global.__mpxOptionsMap[currentInject.moduleId] = memo((props) => {
const firstRef = useRef(true)
const initialRouteRef = useRef({
initialRouteName: firstPage,
initialParams: {}
})

if (firstRef.current) {
// 热启动情况下,app会被销毁重建,将__mpxAppHotLaunched重置保障路由等初始化逻辑正确执行
global.__mpxAppHotLaunched = false
firstRef.current = false
}
if (!global.__mpxAppHotLaunched) {
const { initialRouteName, initialParams } = Mpx.config.rnConfig.parseAppProps?.(props) || {}
initialRouteRef.current.initialRouteName = initialRouteName || initialRouteRef.current.initialRouteName
Expand Down

0 comments on commit fa0b394

Please sign in to comment.