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

useHeaderHeight returns incorrect value for native stack on Android #2661

Open
ykliuiev opened this issue Jan 29, 2025 · 1 comment
Open
Labels
Missing repro This issue need minimum repro scenario Platform: Android This issue is specific to Android

Comments

@ykliuiev
Copy link

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.

Native Stack Simple Stack
Image Image

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

Copy link

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

@github-actions github-actions bot added Missing repro This issue need minimum repro scenario Platform: Android This issue is specific to Android labels Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing repro This issue need minimum repro scenario Platform: Android This issue is specific to Android
Projects
None yet
Development

No branches or pull requests

1 participant