Home IOS Development ios – React Native Expo giving; Utility tried to current modally a view controller that’s already being introduced

ios – React Native Expo giving; Utility tried to current modally a view controller that’s already being introduced

0
ios – React Native Expo giving; Utility tried to current modally a view controller that’s already being introduced

[ad_1]

Im operating into a problem i cant appear to repair … Im utilizing Expo Router and in my structure file in checking if the consumer is authenticated, if they’re, ship them to the (app) which is a tabs structure. If they aren’t authenticated, then return the welcome web page.

After I log in and it goes to point out the primary web page of the tabs, it crashes. But when i load the app again up, because it already has a token it masses the tabs high quality, there appears to be a problem with the redirect which i cant appear to determine.

I did a expo prebuild and ran it in XCode to see if I might see any errors, and the next confirmed up;

*** Terminating app resulting from uncaught exception 'NSInvalidArgumentException', motive: 'Utility tried to current modally a view controller <RCTModalHostViewController: 0x11c4632f0> that's already being introduced by <UIViewController: 0x107b0b7a0>.'
*** First throw name stack:
(
    0   CoreFoundation                      0x00007ff80049928d __exceptionPreprocess + 242
    1   libobjc.A.dylib                     0x00007ff800063894 objc_exception_throw + 48
    2   UIKitCore                           0x00007ff8051be215 -[UIViewController _presentViewController:withAnimationController:completion:] + 5813
    3   UIKitCore                           0x00007ff8051bed86 __63-[UIViewController _presentViewController:animated:completion:]_block_invoke_2 + 70
    4   UIKitCore                           0x00007ff80622eac4 +[UIView(Animation) performWithoutAnimation:] + 84
    5   UIKitCore                           0x00007ff8051becdb __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 211
    6   UIKitCore                           0x00007ff8051bf016 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 637
    7   UIKitCore                           0x00007ff8051bebc8 -[UIViewController _presentViewController:animated:completion:] + 165
    8   UIKitCore                           0x00007ff8051bf0ca -[UIViewController presentViewController:animated:completion:] + 153
    9   RentSafe                            0x00000001031cf284 __76-[RCTModalHostViewManager presentModalHostView:withViewController:animated:]_block_invoke.42 + 212
    10  libdispatch.dylib                   0x0000000106f77747 _dispatch_call_block_and_release + 12
    11  libdispatch.dylib                   0x0000000106f789f7 _dispatch_client_callout + 8
    12  libdispatch.dylib                   0x0000000106f88856 _dispatch_main_queue_drain + 1362
    13  libdispatch.dylib                   0x0000000106f882f6 _dispatch_main_queue_callback_4CF + 31
    14  CoreFoundation                      0x00007ff8003f5850 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    15  CoreFoundation                      0x00007ff8003f018b __CFRunLoopRun + 2463
    16  CoreFoundation                      0x00007ff8003ef409 CFRunLoopRunSpecific + 557
    17  GraphicsServices                    0x00007ff80fcdd187 GSEventRunModal + 137
    18  UIKitCore                           0x00007ff805b703a2 -[UIApplication _run] + 972
    19  UIKitCore                           0x00007ff805b74e10 UIApplicationMain + 123
    20  RentSafe                            0x0000000102d586d0 predominant + 96
    21  dyld                                0x00000001063023ee start_sim + 10
    22  ???                                 0x0000000111cb13a6 0x0 + 4593488806
)
libc++abi: terminating resulting from uncaught exception of sort NSException

This appears to be the trigger;

Utility tried to current modally a view controller <RCTModalHostViewController: 0x11c4632f0> that's already being introduced by <UIViewController: 0x107b0b7a0>.'

I ahve no thought what this implies or find out how to even go about fixing it. Im hopinf somebody might shed some gentle on it. The code in my _layout.tsx file the place the redirect is occurring is as follows;

import { useEffect } from 'react'
import { Stack, useRouter, useSegments } from 'expo-router'
import { AuthProvider, useAuth } from '../context/AuthContext'
import { useFonts } from 'expo-font'
import * as SplashScreen from 'expo-splash-screen'
import { QueryClientProvider, QueryClient } from '@tanstack/react-query'

const queryClient = new QueryClient()

SplashScreen.preventAutoHideAsync()

const InitialLayout = () => {
    const { authState, initialized } = useAuth()
    const segments = useSegments()
    const router = useRouter()

    const [fontsLoaded, fontError] = useFonts({
        'rob-thin': require('../property/fonts/Roboto-Skinny.ttf'),
        'rob-light': require('../property/fonts/Roboto-Mild.ttf'),
    })

    useEffect(() => {
        const loadFonts = async () => {
            if (fontsLoaded) {
                await SplashScreen.hideAsync()
            }
        }
        loadFonts()

        if (! initialized || ! fontsLoaded) return

        const inAuthGroup = segments[0] === '(app)'

        if (authState?.authenticated && !inAuthGroup) {
            router.substitute('/(app)')
        } else if (!authState?.authenticated) {
            router.substitute('/welcome')
        }
    }, [initialized, authState, fontsLoaded])

    if (! fontsLoaded) {
        return null
    }

    return (
        <>
            {authState?.authenticated ? (
                <Stack>
                    <Stack.Display identify="(app)" choices={{ headerShown: false }} />
                </Stack>
            ) : (
                <Stack>
                    <Stack.Display identify="welcome" choices={{ headerShown: false }} />
                    <Stack.Display identify="login" choices={{ headerShown: false }} />
                    <Stack.Display identify="register" choices={{ headerShown: false }} />
                </Stack>
            )}
        </>
    )
}

const RootLayout = () => {
    return (
        <QueryClientProvider shopper={queryClient}>
            <AuthProvider>
                <InitialLayout />
            </AuthProvider>
        </QueryClientProvider>
    )
}

export default RootLayout

If anybody has any perception or has seen this earlier than it could be drastically appreciated. I’ve spent days looking for an answer.

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here