当在createSwitchNavigator中导航或导航时,应用程序停止工作

时间:2019-08-12 15:21:41

标签: javascript react-native react-navigation

当用户在主屏幕中选择注销时,我有一些代码可以导航到登录屏幕。不幸的是,该应用程序在导航到“登录”屏幕时停止工作。我的意思是,该应用程序关闭并显示一个对话框,并且该应用程序已停止。

我的代码有什么问题?

这是我的SwitchNavigator

const AppSwitchNavigator = createAnimatedSwitchNavigator({
    SplashScreen: {
        screen: screenSplash
    },
    LoginScreen: {
        screen: screenLogin
    },
    MainScreen: {
        screen: AppTab
    }
}, {
        initialRouteName: 'SplashScreen',
        transition: (
            <Transition.Together>
                <Transition.Out
                    type="slide-bottom"
                    durationMs={400}
                    interpolation="easeIn"
                />
                <Transition.In type="fade" durationMs={500} />
            </Transition.Together>
        ),
    });

用户注销时调用此函数:

async logoutProses() {
        this.setState({ isLoading: true })
        await firebase.auth().signOut()
        await AsyncStorage.removeItem("userData")
        await GoogleSignin.signOut()
        this.setState({ isLoading: false })
        this.props.navigation.navigate("LoginScreen")
}

控制台调试中的错误信息:

Error: No user currently signed in.
    at createErrorFromErrorData (fb338eb7-b190-4075-a4c6-86ad832e0cdb:2108)
    at fb338eb7-b190-4075-a4c6-86ad832e0cdb:2060
    at MessageQueue.__invokeCallback (fb338eb7-b190-4075-a4c6-86ad832e0cdb:2627)
    at fb338eb7-b190-4075-a4c6-86ad832e0cdb:2358
    at MessageQueue.__guard (fb338eb7-b190-4075-a4c6-86ad832e0cdb:2531)
    at MessageQueue.invokeCallbackAndReturnFlushedQueue (fb338eb7-b190-4075-a4c6-86ad832e0cdb:2357)
    at e (RNDebuggerWorker.js:1)
reactConsoleErrorHandler @ fb338eb7-b190-4075-a4c6-86ad832e0cdb:22755
console.error @ fb338eb7-b190-4075-a4c6-86ad832e0cdb:67435
logoutProses$ @ fb338eb7-b190-4075-a4c6-86ad832e0cdb:205207
tryCatch @ fb338eb7-b190-4075-a4c6-86ad832e0cdb:23070
invoke @ fb338eb7-b190-4075-a4c6-86ad832e0cdb:23245
prototype.(anonymous function) @ fb338eb7-b190-4075-a4c6-86ad832e0cdb:23113
tryCatch @ fb338eb7-b190-4075-a4c6-86ad832e0cdb:23070
invoke @ fb338eb7-b190-4075-a4c6-86ad832e0cdb:23146
(anonymous) @ fb338eb7-b190-4075-a4c6-86ad832e0cdb:23158
tryCallOne @ fb338eb7-b190-4075-a4c6-86ad832e0cdb:24362
(anonymous) @ fb338eb7-b190-4075-a4c6-86ad832e0cdb:24463
(anonymous) @ fb338eb7-b190-4075-a4c6-86ad832e0cdb:27856
_callTimer @ fb338eb7-b190-4075-a4c6-86ad832e0cdb:27745
_callImmediatesPass @ fb338eb7-b190-4075-a4c6-86ad832e0cdb:27781
callImmediates @ fb338eb7-b190-4075-a4c6-86ad832e0cdb:28000
__callImmediates @ fb338eb7-b190-4075-a4c6-86ad832e0cdb:2548
(anonymous) @ fb338eb7-b190-4075-a4c6-86ad832e0cdb:2369
__guard @ fb338eb7-b190-4075-a4c6-86ad832e0cdb:2531
flushedQueue @ fb338eb7-b190-4075-a4c6-86ad832e0cdb:2368
invokeCallbackAndReturnFlushedQueue @ fb338eb7-b190-4075-a4c6-86ad832e0cdb:2361
e @ RNDebuggerWorker.js:1
fb338eb7-b190-4075-a4c6-86ad832e0cdb:22755 Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
    in AkunScreen (created by ConnectFunction)
    in ConnectFunction (at react-navigation-collapsible/index.js:302)
    in RCTView (at View.js:45)
    in View (at react-navigation-collapsible/index.js:301)
    in _withCollapsible (at SceneView.js:9)
    in SceneView (at StackViewLayout.tsx:888)
    in RCTView (at View.js:45)
    in View (at StackViewLayout.tsx:887)
    in RCTView (at View.js:45)
    in View (at StackViewLayout.tsx:886)
    in RCTView (at View.js:45)
    in View (at createAnimatedComponent.js:151)
    in AnimatedComponent (at StackViewCard.tsx:93)
    in RNSScreen (at createAnimatedComponent.js:151)
    in AnimatedComponent (at screens.native.js:61)
    in Screen (at StackViewCard.tsx:80)
    in Card (at createPointerEventsContainer.tsx:95)
    in Container (at StackViewLayout.tsx:971)
    in RNSScreenContainer (at screens.native.js:85)
    in ScreenContainer (at StackViewLayout.tsx:383)
    in RCTView (at View.js:45)
    in View (at createAnimatedComponent.js:151)
    in AnimatedComponent (at StackViewLayout.tsx:379)
    in PanGestureHandler (at StackViewLayout.tsx:372)
    in StackViewLayout (at withOrientation.js:30)
    in withOrientation (at StackView.tsx:103)
    in RCTView (at View.js:45)
    in View (at Transitioner.tsx:267)
    in Transitioner (at StackView.tsx:40)
    in StackView (at createNavigator.js:61)
    in Navigator (at createKeyboardAwareNavigator.js:12)
    in KeyboardAwareNavigator (at SceneView.js:9)
    in SceneView (at createTabNavigator.js:39)
    in RCTView (at View.js:45)
    in View (at createAnimatedComponent.js:151)
    in AnimatedComponent (at BottomNavigation.js:646)
    in RCTView (at View.js:45)
    in View (at createAnimatedComponent.js:151)
    in AnimatedComponent (at BottomNavigation.js:631)
    in RCTView (at View.js:45)
    in View (at BottomNavigation.js:615)
    in RCTView (at View.js:45)
    in View (at BottomNavigation.js:611)
    in BottomNavigation (created by Context.Consumer)
    in ThemeProvider (created by Context.Consumer)
    in withTheme(BottomNavigation) (at createMaterialBottomTabNavigator.js:51)
    in BottomNavigationView (at createTabNavigator.js:197)
    in NavigationView (at createNavigator.js:61)
    in Navigator (at SceneView.js:9)

0 个答案:

没有答案