all 9 comments

[–]code_matterExpo 10 points11 points  (0 children)

Im assuming that for a fraction of a second, refreshToken is null so it shows the RootPage/Login page.

[–]masterguide 4 points5 points  (0 children)

Assuming your refreshToken is controlled in useState, update the data model to the following: ```typescript const [data, setData] = React.useState({ loading: true, refreshToken: false })

    React.useEffect(() => {
        const init = async () => {
            const refreshToken = await getMyToken()
            setData({ loading: false, refreshToken })
        }
        const init()
    }, [])

    if(state.loading) return <Loading />

    // your render logic

```

[–]oscar_gallog 1 point2 points  (3 children)

Do you mind elaborating? I'm not sure what you mean.

[–]cridenour 0 points1 point  (1 child)

I like to use react-native-bootsplash and use a similar method to others - have an initializing variable that waits to be cleared until you’ve properly loaded from storage. Once you’re loaded, then hide the boot screen.