How do you get the screenOptions in a React Navigation screen component?

Viewed 28

I know I can do setOptions on the navigation object, but I can't seem to find the get version of it. How do I obtain that information, namely I want to know if headerLarge is enabled.

What I have done as a workaround for now is have a useEffect on the header component that stores the screenOptions data into a context object keyed by route key. With a return method that will remove it from the context when the header is unmounted.

1 Answers

You can set headerLarge using below code :

function MyStack() {
  return (
    <Stack.Navigator>
      <Stack.Screen
        name="Home"
        options={{
          headerLargeTitle: true,
        }}
        component={HomeScreen}
      />
    </Stack.Navigator>
  );
}

PS : headerLarge is only for iOS.

Related