Learn Courses My Dashboard

Issues Getting Data in First View

Hello!

I’m working on my own app, but I’m running into a sticky problem…

init() {
    
        // Get the user's data
        getUserData()
        
    }

I have my getUserData() method in my init() within my ContentView. Everything works fine when I nagivage to other views in my app, but when I run the app, the first view isn’t displaying any data, almost as if this init() method hasn’t run yet. After navigating to another view (which shows that data has been retrieved from the database) and then go back to the entry view, the data shows up.

When I start up the app:

After navigating to another view and coming back:

I am already using the .onAppear on this main view, but it doesn’t seem to fire until I circle around back to it.

What am I missing in my code??

Thanks for the help!

It’s pretty much impossible for us to tell without more code. What does your getUserData function look like? What does your ContentView look like?