expo / ex-navigation

Route-centric navigation for React Native
997 stars 201 forks source link

Sliding tabs, transitioner frozen #429

Open JulianKingman opened 7 years ago

JulianKingman commented 7 years ago

Under certain circumstances, the transitioned freezes when navigating on a tab navigator. Possibly related to #415

For example, if I have a route that contains a tab navigator, then I push a screen to that route, it will sometimes appear unresponsive, while what's actually happened is the transitioned is fullscreen, but the component being transitioned in halts, sometimes mid-way.

JulianKingman commented 7 years ago

I figured out a work-around, which is to properly reset the tabs. Currently, the navigation state is correct when I navigate to them the first time, but on subsequent times, the state is wrong, so I add this static reset function, which I run whenever the tab view receives focus:

static reset() {
    const tabNavigator = Store.getState().navigation.navigators.MyDueListTabs;
    Store.dispatch(NavigationActions.setCurrentNavigator(
      'TabNavigator', //the tabs themselves
      'TabNavigatorParentStack', //the view they live on, referenced in my drawer navigator
      'slidingTab', //the type
      {}, //options I think?
      tabNavigator && tabNavigator.routes, //the tab routes, if they exist (they don't exist until rendered)
      Store.getState().appState.activeTab || 0, //tab index, this is my way of persisting the last tab I was on
    ));
  }