title: React-navigation touches sometimes don't work
body: <p>I'm hoping this is a known problem as I can't provide much to go on to get help solving it.</p>
  
  <p>I'm using react-navigation for my app with the following setup:</p>
  
  <ul>
  <li>AppContainer
  
  <ul>
  <li>Splash Screen</li>
  <li>Setup Screen (A stack navigator)</li>
  <li>Main screen (A stack navigator)</li>
  </ul></li>
  </ul>
  
  <p>When my app starts it goes to the splash screen which decides if this is the first time running or not and depending on this decision calls <code>this.props.navigation.navigate()</code> with either main screen or setup screen.</p>
  
  <p>So far this all works and is fairly standard. </p>
  
  <p>When my app is launched for the first time the user is sent to the setup screen where they navigate through a series of screens entering data and selecting a next button to proceed to the next screen. This is where the problem occur. My first screen simply has some text and a next button (which is a regular button component) which when clicked calls <code>this.props.navigation.push('nextviewname', {data: data})</code> to move to the next view.</p>
  
  <p>The next view contains a textinput as well as back and next buttons which is where I'm having problems. When I reach this screen after freshly installing a release version of my app onto my Android X phone none of the inputs work. I can't:</p>
  
  <ul>
  <li>Click next of back</li>
  <li>Click the back arrow in the top left that is part of the header</li>
  <li>Click the text input (the cursor does briefly show up in the text input but the keyboard never appears)</li>
  <li>Click the hardware back key</li>
  </ul>
  
  <p>On very rare occasions some of the above does work (e.g. the text input will sometimes work) and sometimes I'll even make it to the next step of my setup but it's rare that I make it all the way through</p>
  
  <p>Weirdly this all works when I'm debugging my app on my phone.</p>
  
  <p><strong>Update:</strong> I've just tested on an Android 9 emulator and I'm getting the same issue.</p>
  
  <p><strong>Update 2:</strong> This is getting weird, when the app is in a broken state I can still bring up the react native debug menu however when I click Toggle Inspector nothing happens (i.e. I don't get the inspector UI). It's looking like this is somehow breaking everything.</p>
  
  <p>Has anyone seen/solved this issue before? At the moment it's effectively made my app useless.</p>
  
  <p><strong>Update 3:</strong> Some code to hopefully make things clearer:</p>
  
  <pre><code>const SetupUser = createStackNavigator(
    {
      SetupUser: WelcomeScreen,
      SetupName: UserName,
      SetupCurrentWeight: CurrentWeight,
      SetupGoalWeight: GoalWeight,
      SetupGoalDate: GoalDate,
      Summary: Summary,
      LogWeight: LogWeight,
    },
    {
      defaultNavigationOptions: {
        headerStyle: {
          backgroundColor: '#001830',
        },
        headerTintColor: '#fff',
        headerTitleStyle: {
          fontWeight: 'bold',
        },
      },
    },
  );
  
  const MainApp = createStackNavigator(
    {
      LogWeight: LogWeight,
      LogWeightSummary: LogWeightSummary,
    },
    {
      defaultNavigationOptions: {
        headerStyle: {
          backgroundColor: '#001830',
        },
        headerTintColor: '#fff',
        headerTitleStyle: {
          fontWeight: 'bold',
        },
      },
    },
  );
  
  export default createAppContainer(
    createSwitchNavigator(
      {
        MainApp: MainApp,
        SplashScreen: SplashScreen,
        SetupUser: SetupUser,
      },
      {
        initialRouteName: 'SplashScreen',
      },
    ),
  );
  </code></pre>
  
  <p>In getting this code snippit together (I've removed the tab navigator as the error is still there even without it) I think I've managed to track down the source of the issue however I'm still not sure how to fix it. The first view loaded is the splash screen which looks like this:</p>
  
  <pre><code>export default class SplashScreen extends React.Component {
  constructor(props) {
      super(props);
  
      GoBinder.verifyDatabase()
        .then(GoBinder.getLastUser())
        .then(user =&gt; {
          this.props.navigation.navigate(
            user.user == null ? 'SetupUser' : 'MainApp',
          );
        })
        .catch(error =&gt; {
          GoBinder.toast('Error while checking initial user state: ' + error);
        });
    }
  render() {
      return (
        &lt;View style={styles.container}&gt;
          &lt;ActivityIndicator /&gt;
          &lt;StatusBar barStyle="default" /&gt;
        &lt;/View&gt;
      );
    }
  }
  </code></pre>
  
  <p>In the above code, GoBinder.verifyDatabase() and GoBinder.getLastUser() are calls to native code which perform some database operation to get things setup and check to see if there are any existing users. I believe the issue is <code>this.props.navigation.navigate</code> is firing too quickly which is causing react-navigation to load the next screen but get messed up in the process.</p>
  
  <p>I've tried following the suggestions in this post <a href="https://www.novemberfive.co/blog/react-performance-navigation-animations" rel="nofollow noreferrer">https://www.novemberfive.co/blog/react-performance-navigation-animations</a> about moving blocking code into <code>InteractionManager.runAfterInteractions</code> under <code>componentDidMount</code> however this made no difference. However, it I manually trigger the move to the new screen using a button everything works correctly so its really looking like the act of programatically changing screens is messing things up.</p>
  
  <p><strong>Update 4:</strong> 
  Looks like I jumped the gun a bit, its still freezing up a fair bit, moving my answer into an update:</p>
  
  <p>So I'm not sure if this is the best solution but I have found a workaround. I am now calling my database code in <code>InteractionManager.runArfetInteraction()</code> as suggested in <a href="https://www.novemberfive.co/blog/react-performance-navigation-animations" rel="nofollow noreferrer">https://www.novemberfive.co/blog/react-performance-navigation-animations</a>. I am then calling <code>setState</code> with the result of the DB functions to store the result. Finally, I am using a callback on <code>setState</code> to trigger the actual navigation. My complete working code is:</p>
  
  <pre><code>componentDidMount() {
      InteractionManager.runAfterInteractions(() =&gt; {
        GoBinder.verifyDatabase()
          .then(
            GoBinder.getLastUser().then(user =&gt; {
              this.setState(
                {
                  user: user.user,
                },
                () =&gt; {
                  this.props.navigation.navigate(
                    this.state.user == null ? 'SetupUser' : 'MainApp',
                  );
                },
              );
            }),
          )
          .catch(error =&gt; {
            GoBinder.toast('Error while checking initial user state: ' + error);
          });
      });
    }
  </code></pre>
  
  <p>Thanks for your help</p>