question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

headerRight randomly position the component incorrectly

See original GitHub issue

I was testing the createNativeStackNavigation and ended up having this random issue where the component rendered by headerRight is being positioned incorrectly sometimes. There’s nothing special in my code, I am just rendering a <Button> from react-native.

Here’s the source code: https://github.com/lnmunhoz/react-native-experiments/blob/master/react-navigation-examples/examples/NativeNavigation.tsx.

Kapture 2020-03-21 at 20 56 50

Update

The issue also happens when the headerLargeTitle is false.

image

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:48 (19 by maintainers)

github_iconTop GitHub Comments

5reactions
markmssdcommented, Mar 28, 2020

I have a workaround if it’s a blocker for anyone here https://github.com/react-navigation/react-navigation/issues/6746#issuecomment-583897436:

As a workaround I show the Icon after a few ms:

const [shouldRenderIcon, setShouldRenderIcon] = useState(false)

useEffect(() => {
const nbr = setTimeout(() => setShouldRenderIcon(true), 200)
return () => clearTimeout(nbr)
}, [])

return shouldRenderIcon ? <MyIcon /> : null
3reactions
jadarcommented, Aug 5, 2022

It seems there’s been a bit of a regression here. I am seeing the header title being randomly positioned to the right when using NativeStack from react-navigation. Opening the view debugger in Xcode shows the width as 0, which would explain why it’s “to the right”, it’s centered with the width being 0 and shows the overflow.

Screen Shot 2022-08-05 at 12 27 48 PM

$  grep react-native-screens package.json     
    "react-native-screens": "^3.13.1",
$  grep react-native package.json 
...
    "react-native": "0.67.4",
...
$  grep react-navigation package.json
    "@react-navigation/bottom-tabs": "^6.3.1",
    "@react-navigation/elements": "^1.3.3",
    "@react-navigation/native": "^6.0.10",
    "@react-navigation/native-stack": "^6.6.1",
Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there a good way to set headerRight to pass onPress event ...
First thing you cannot access navigation outside of the NavigationContainer so remove navigation from your App declaration :
Read more >
react-navigation-header-buttons - npm
setOptions({ // in your app, extract the arrow function into a separate component // to avoid creating a new one every time headerRight: ......
Read more >
Policy - Portland Public Schools
Random controlled substance testing shall be a minimum of 50 percent of the number of driver positions each selection period.
Read more >
The Conjunctive and Disjunctive Events Bias - Farnam Street
This article is an introduction to Conjunctive and Disjunctive Events Bias that details how these two biases impact our decisions.
Read more >
10 Emotion-Coaching Phrases to Use When Your Child is Upset
Or how for some reason falling down this time and in this place, ... A key part of being your child's emotion coach...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found