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.

[native-stack] [iOS] BottomTabNavigator hide/show bug in Native Stack

See original GitHub issue

Moved from react-navigation/react-navigation#6772. Originally opened by @guvenakcoban


The problem

  • When I tried to hide bottom tabs in native stack, tabs going out but the screen’s height doesn’t update. If I change orientation of device or pull the status bar, it’s fixing. See the gif.
  • This problem is only appear when using native stack navigator, there’s no problem with createStackNavigator.

ezgif com-resize

Code

  • Basic tab based navigation with native stack
import React from 'react';
import { View, Text, TouchableOpacity } from 'react-native';
import { NavigationNativeContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { useScreens } from 'react-native-screens';

useScreens();

const Home = props => {
  return (
    <View
      style={{
        flex: 1,
        backgroundColor: 'red',
        alignItems: 'center',
        justifyContent: 'center',
      }}>
      <Text>Home Screen</Text>
      <TouchableOpacity onPress={() => props.navigation.navigate('Settings')}>
        <Text>GoToSettings</Text>
      </TouchableOpacity>
    </View>
  );
};

const Profile = props => {
  return (
    <View
      style={{
        flex: 1,
        backgroundColor: 'red',
        alignItems: 'center',
        justifyContent: 'center',
      }}>
      <Text>Profile Screen</Text>
    </View>
  );
};

const Settings = props => {
  return (
    <View
      style={{
        flex: 1,
        backgroundColor: 'red',
        alignItems: 'center',
        justifyContent: 'center',
      }}>
      <Text>Settings Screen</Text>
    </View>
  );
};

const Stack = createNativeStackNavigator();
const Tab = createBottomTabNavigator();

function HomeStackScreen() {
  return (
    <Stack.Navigator>
      <Stack.Screen name="Home" component={Home} />
      <Stack.Screen name="Settings" component={Settings} />
    </Stack.Navigator>
  );
}

const App = () => {
  return (
    <NavigationNativeContainer>
      <Tab.Navigator
        screenOptions={({ route }) => {
          const routeName = route.state
            ? route.state.routes[route.state.index].name
            : 'Home';

          return { tabBarVisible: routeName === 'Home' };
        }}
        tabBarOptions={{ inactiveBackgroundColor: 'green' }}>
        <Tab.Screen name="Home" component={HomeStackScreen} />
        <Tab.Screen name="Profile" component={Profile} />
      </Tab.Navigator>
    </NavigationNativeContainer>
  );
};

export default App;

Your Environment

software version
@react-navigation/core ^5.0.0-alpha.27
@react-navigation/native ^5.0.0-alpha.18
@react-navigation/native-stack ^5.0.0-alpha.16
react-native-screens ^2.0.0-alpha.18
@react-navigation/bottom-tabs ^5.0.0-alpha.25

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
satya164commented, Jul 31, 2020

The page doesn’t exist doesn’t mean that you can’t do it. I’m pretty sure you can nest a tab navigator inside the first screen of the stack in v4.

0reactions
watadarkstarcommented, Jul 31, 2020

@satya164 Haha yeah I realized that after I posted this comment. Long day!

Read more comments on GitHub >

github_iconTop Results From Across the Web

[iOS] BottomTabNavigator hide/show bug in Native Stack
The problem When I tried to hide bottom tabs in native stack, tabs going out but the screen's height doesn't update.
Read more >
react native - stack from NativeStackNavigator (nested in ...
Problem: When I press tab3 (from the BottomTabNavigator) I see screen 1. If I press a button on screen 1 then it will...
Read more >
Hiding tab bar in specific screens
Sometimes we may want to hide the tab bar in specific screens in a stack navigator nested in a tab navigator. Let's say...
Read more >
React Navigation v6 stack navigator with headerLargeTitle ...
In my app I am trying to use React Navigation's stack navigator with headerLargeTitle and headerTransparent enabled. My implementation looks like this:.
Read more >
A guide to React Native Navigation
... used methods of navigation with React Native — Stack Navigator, Bottom Tab Navigator, ... To install native dependencies for iOS, run:
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