Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: 修复 RN 生命周期执行顺序 #1890

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

wangshunnn
Copy link
Collaborator

Fix

  • 和微信小程序生命期周期执行顺序拉齐
    • App onLaunch 调整至页面 created 之前
    • Page onLoad 调整至组件 ready 之前
  • 修复目前页面 onShow onHide 未执行 bug

@@ -384,7 +400,9 @@ const pageStatusMap = global.__mpxPageStatusMap = reactive({})

function usePageStatus (navigation, pageId) {
navigation.pageId = pageId
set(pageStatusMap, pageId, '')
if (!hasOwn(pageStatusMap, pageId)) {
set(pageStatusMap, pageId, '')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

确认一下为何page首次会渲染两次

Copy link
Collaborator Author

@wangshunnn wangshunnn Mar 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

定位到是 useHeaderHeight() hook 运行结果变化导致的,内部是个 useContext,第一次运行结果是 0,第二次正常值比如 101

import { useHeaderHeight } from '@react-navigation/elements';

const { PortalHost, useSafeAreaInsets, GestureHandlerRootView, useHeaderHeight } = global.__navigationHelper

height: ReactNative.Dimensions.get('screen').height - useHeaderHeight()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants