useHeaderHeight returns incorrect value for native stack on Android #2661
Labels
Missing repro
This issue need minimum repro scenario
Platform: Android
This issue is specific to Android
Description
I noticed that useHeaderHeight returns inconsistent values for native vs. simple stacks on Android. For example, native stack returns 246, whereas simple stack yields 95 as a value. This may be related to Screen.kt#L164, where notifyHeaderHeightChange(t) might be passing an unexpectedly large t value.
I verified this with a HeaderHeightView component in the react-navigation/example app, and the native and simple stacks show different values.
Steps to reproduce
It's reproducible in https://github.com/react-navigation/react-navigation/tree/main/example as well as in the Example app in this repo.
Calling useHeaderHeight in apps/src/screens/SimpleNativeStack.tsx will log two times:
import { useHeaderHeight } from '@react-navigation/elements';
const MainScreen = ({ navigation }: MainScreenProps): React.JSX.Element => {
const header = useHeaderHeight();
console.log('header', header);
logs:
header height: 56
header height: 126.711111
Snack or a link to a repository
https://github.com/react-navigation/react-navigation/tree/main/example
Screens version
4.3.0
React Native version
0.76.2
Platforms
Android
JavaScript runtime
None
Workflow
None
Architecture
Paper (Old Architecture)
Build type
None
Device
Real device
Device model
Samsung Galaxy A53 Android 14, Google Pixel 6 Pro Android 15
Acknowledgements
Yes
The text was updated successfully, but these errors were encountered: