与这个导航库有一些问题。
我看到所有组件都是相互独立的,但我需要在所有屏幕上都有一个类似于HOC的组件。
例如,如果我没有连接,我希望只显示一个屏幕,如果连接可用,则显示基于当前选项卡的应用程序。
我该怎么做?
谢谢你的建议。
寄存器组件代码
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.');
}
};发布于 2018-02-09 17:17:28
您需要NetInfo API来检查连接状态。并使用导航的反应-本机导航移动到右边的屏幕-或单屏幕应用程序或基于标签的应用程序。
NetInfo.getConnectionInfo().then((connectionInfo) => {
if (connectionInfo.type === 'none') {
Navigation.startSingleScreenApp(params);
} else {
Navigation.startTabBasedApp(params);
}
});https://stackoverflow.com/questions/48710590
复制相似问题