How to hide stack navigation header from a single screen in react-navigation v5
Asked Answered
M

2

9

My app has 5 components (screens), I am using stack navigation version 5, I need the headers for all screens except one screen, I tried to do this via option inside screens like this:

This is my code:

const Stack = createStackNavigator();
const MainStack = () => ({
    return(
        <NavigationContainer>
            <Stack.Navigator>
                <Stack.Screen name="MyTabs" component={MyTabs} />
                <Stack.Screen name="Direct" component={Direct} />
                <Stack.Screen name="Like" component={Like} />
                <Stack.Screen name="Search" component={Search} />
                <Stack.Screen name="Home" component={Home} />
            </Stack.Navigator>
        </NavigationContainer>
    )
)}
Minyan answered 16/2, 2020 at 14:15 Comment(3)
Did you try setting the header options inside the component using static navigationOptions = { header:null }. I am not sure if it will work on React Navigation v5.Vibration
No buddy, static navigationOptions doesn't work in version 5Minyan
Oops! Sorry then. I haven't yet moved to V5! Anyways, good luck :)Vibration
D
14

use options={{ headerShown: false }}

Delmerdelmor answered 16/2, 2020 at 14:59 Comment(1)
thanks worked for me "navigationOptions becomes options prop on Screen" in v5Forty
B
5
  1. in your navigation options={{ headerShown: false }}
  2. from your component navigation.setOptions({ headerShown: false })
Berg answered 29/6, 2020 at 8:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.