小编Rub*_*shi的帖子

对导航进行排队,直到屏幕安装完毕然后进行导航

当用户通过单击通知打开应用程序时,我尝试导航到底部选项卡导航器上的某个屏幕。

查看官方文档Navigating without the navigation prop,我的主导航器设置如下:

import {navigationRef, isReadyRef} from './root';

const MainNav = _ => {
  if (isLoading) {
    return isFirstTime ? (<OnBoarding />) : (<SplashScreen />);
  }

  return (
    <NavigationContainer
      ref={navigationRef}
      onReady={() => {isReadyRef.current = true}}>
        {!token ? <AuthNav /> : <AppNav />}
    </NavigationContainer>
  );
}
Run Code Online (Sandbox Code Playgroud)

我的root.js如下:

import * as React from 'react';

export const isReadyRef = React.createRef();

export const navigationRef = React.createRef();

export function navigate(name, params) {
  if (isReadyRef.current && navigationRef.current) {
    // Perform navigation …
Run Code Online (Sandbox Code Playgroud)

react-native react-redux react-navigation react-native-onesignal

5
推荐指数
0
解决办法
1019
查看次数