'React Native: React Navigation: Using "setOptions" to set options outside of screen

In React Navigation, we can change the options property of a Screen using navigation.setOptions({ /* new options */ }) inside this screen.

<Stack.Screen name="Custom" component={CustomScreen} options={{ title:  'Custom' /* Using "setOptions" will change this */ }} />

But in my case, I don't want to modify the options of the Screen I am in but the screenOptions of the Navigator the Screen is inside:

<Stack.Navigator screenOptions={{ headerShown: true /* For example, changing this to false */ }}>
  <Stack.Screen name="Custom" component={CustomScreen} options={{ title:  'Custom' }} />
</Stack.Navigator>

Is this possible?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source