16

I dynamically set the "headerShown" screen option but I can't sort out how to read the options from within a functional component

<Stack.Navigator
    screenOptions={{
      headerShown: showHeader
}}>

Ive tried the navigation, route and state objects from within the component using useNavigation, useRoute and useNavigationState respectively and none seem to have a way to get the screen option values.

jwanga
  • 4,166
  • 4
  • 26
  • 27

1 Answers1

-2

if your component is a screen, you can access the options of screen by doing this

function MyComponent({scene}) {
    console.log(scene.descriptor.options);
}
Camerev
  • 167
  • 1
  • 11