software-mansion / react-native-screens

Native navigation primitives for your React Native app.
MIT License
2.99k stars 507 forks source link

Wrong layout when updating headerLeft and headerRight on new arch #2231

Closed janicduplessis closed 1 month ago

janicduplessis commented 1 month ago

Description

When the headerLeft is removed and headerRight has updated layout at the same time in native-stack, it results in the headerRight having incorrect layout.

Workaround:

If I update them in separate ticks (using setTimeout) layout is correct.

Steps to reproduce

Using this code in FabricExample app HeaderOptions.tsx

Updating both headerLeft and headerRight (bug):

image image

Updating only headerRight (correct)

image image

Snack or a link to a repository

https://github.com/janicduplessis/react-native-screens/tree/%40janic/header-bug-1

Screens version

main@e5a6220

React Native version

0.74

Platforms

iOS

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Fabric (New Architecture)

Build type

Debug mode

Device

iOS simulator

Device model

No response

Acknowledgements

Yes

alduzy commented 1 month ago

Hi! Thanks for reporting. I'm going to take a look at it. ~Wrapping the right item in a useCallback hook should do the trick until the problem's solved.~ Edit: I misunderstood the issue initially, but I can see the problem now.