React Native Navigation - startTabBasedApp - only load tab if clicked on

488 Views Asked by At

When using startTabBasedApp(params) in React Native Navigation (by Wix), all of the tabs load at once.

Is there a way to make it so that only the initial tab loads? And then only after clicking on another tab does that tab load?

2

There are 2 best solutions below

0
On

A possible workaround is to use the following within the component:

onNavigatorEvent(event) {
  switch (event.id) {
    case "bottomTabSelected":
      this.setState({ didPressTab: true })
      break
    case "willAppear":
  ApplicationScreensManager.getInstance().registerCurrentActiveScreen(ApplicationScreens.WebViewContainerScreen)
     }
      break
  }
}

while this case "bottomTabSelected": is fired only when selecting a tab, then you can set the state raising a flag and only then do whatever you intended on when pressing the tab.

good luck

0
On

I don't believe it's possible. See this comment for more information, it seems like they intended this behaviour.