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.

Blank screen when navigate between nested stacks

See original GitHub issue

Using enableScreens() cause a blank screen when navigating between nested stacks. Here’s a sample App.js to reproduce the issue:

import React,{Component} from "react";
import {createAppContainer} from "react-navigation";
import {createStackNavigator} from "react-navigation-stack";
import {View,Text} from "react-native";
import {enableScreens} from "react-native-screens";

class Screen1 extends Component {
        render() {
                return (
                <View>
                        <Text>Screen 1</Text>
                        <Text onPress={() => this.props.navigation.navigate("Screen2")}>Go to Screen2</Text>
                </View>
                )
        }
}

class Screen2 extends Component {
        render() {
                return (
                <View>
                        <Text>Screen 2</Text>
                        <Text onPress={() => this.props.navigation.navigate("Screen1")}>Back to Screen1</Text>
                </View>
                )
        }
}

enableScreens();

export default createAppContainer(createStackNavigator({
        NestedStack1: createStackNavigator({
                Screen1: createStackNavigator({Screen1: Screen1}),
        }),

        NestedStack2: createStackNavigator({
                Screen2: createStackNavigator({Screen2: Screen2}),
        }),
}));

Going back to Screen1 show a blank screen instead of the expected text. The issue goes away when commenting the enableScreens() function call.

Only tested on Android, currently don’t know about iOS.

My environment:

  • react-native 0.61.5
  • react-navigation 4.0.10
  • react-native-screens 2.0.0-alpha.22

Related issues are #208 and maybe #238.

Regards, Claudio

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:13
  • Comments:7

github_iconTop GitHub Comments

1reaction
clamiaxcommented, Jan 23, 2020

@509dave16 Thanks for your feedback! I’m not using expo but following your hints I noticed that the following packages was not updated:

  • react-navigation-tabs (was 1.2.0)
  • react-navigation-stack (was 1.5.3)

It was a bit of a pain to upgrade them, something broke here or there and I had to change some of my code. A partial list of stuff I had to upgrade, some of which required to be uninstalled first:

  • react-native-screens (of course)
  • react-native-reanimated
  • react-native-safe-area-context
  • react-native-safe-area-view
  • react-navigation
  • react-navigation-drawer
  • react-navigation-stack
  • react-navigation-tabs

After I was able to make the App starts and make it working again the issue seems indeed to be solved.

1reaction
509dave16commented, Jan 22, 2020

@OscarYuen @clamiax @Barney4242 @eslynunezk4 @trexpert I am not sure if any of you are using Expo. So the following solution may or may not apply due to Expo being a heavily modified version of React Native. But in any case the above problem that you are facing, is the same as mine outlined here in an issue I created in another repo: https://github.com/react-navigation/tabs/issues/241

I found that upgrading Expo to SDK36 also upgraded the versions of supported packages, including react-native-screens. With the newly updated dependencies, the rendering of a nested StackNavigator screens on Android works again for me.

Here are my current dependencies related to react-navigation:

software version
react-navigation 4.0.10
react-navigation-tabs 2.7.0
react-navigation-stack 2.0.15
react-native-reanimated 1.4.0
react-native-gesture-handler 1.5.0
react-native-screens 2.0.0-alpha.12
react-native 0.61.4
expo 36
Read more comments on GitHub >

github_iconTop Results From Across the Web

React native nested stack navigation showing empty screen
We can't put Navigator inside View, so you need to change the Products.tsx file to import { Route, Link } from 'react-router-dom'; ...
Read more >
All the Contents of the screen disappears and a white screen ...
[Solved]-React Navigation (Stack Navigation Issue) : All the Contents of the screen disappears and a white screen with title on it is shown-React...
Read more >
Common mistakes - React Navigation
Common mistakes. This section attempts to outline issues that users frequently encounter when first getting accustomed to using React Navigation and serves ...
Read more >
Routing with React Navigation and Nesting ... - Section.io
The stack navigator is nested in the tab navigator. Fourth Step-Adding buttons. We will add buttons to switch between the two screens, if ......
Read more >
createStackNavigator - React Navigation - Netlify
Provides a way for your app to transition between screens where each new screen is placed on top of a stack. By default...
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