Андрей Гузюк
Андрей Гузюк

Reputation: 2164

React native wix/react-native-navigation

Having some issues with this navigation library.
I see that all components independent, but i need to have like HOC on top of all screens.
For example if i have no connection i would like to show only one screen and if connection available - show current tab based app

How do i can do this?

Thanks for any ideas.

Register components code

const registerScreens = (appType, store) => {
  switch (appType) {
    case appTypes.ROOT_APP: {
      Navigation.registerComponent(screens.APP, () => App, store, ApolloProvider, { client });
      break;
    }
    case appTypes.SINGLE_BASED_APP:
      Navigation.registerComponent(screens.ONBOARDING, () => OnboardingContainer, store, ApolloProvider, { client });
      break;
    case appTypes.TAB_BASED_APP:
      // App Screens
      Navigation.registerComponent(screens.DISCOVER, () => DiscoverContainer, store, ApolloProvider, { client });
      break;
    default:
      throw new Error('appType is not defined.');
  }
};

Upvotes: 1

Views: 517

Answers (1)

vijayst
vijayst

Reputation: 21836

You need NetInfo API in React native for checking connection status. And use Navigation of react-native-navigation to move to the right screen - either single screen app or tab based app.

NetInfo.getConnectionInfo().then((connectionInfo) => {
  if (connectionInfo.type === 'none') {
    Navigation.startSingleScreenApp(params);
  } else {
    Navigation.startTabBasedApp(params);
  }
});

Upvotes: 1

Related Questions