Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No ObservableObject of type Store<AppState, AppAction, World> found. A View.environmentObject(_:) for Store<AppState, AppAction, World> may be missing as an ancestor of this view.: file SwiftUI, line 0 #2

Closed
sm0nster opened this issue Apr 5, 2020 · 10 comments

Comments

@sm0nster
Copy link

sm0nster commented Apr 5, 2020

Hey, I've read the article (kudos for it) and tried to play around with your structure but I'm getting fatal error when trying to get to recipe details from recipes listing:

Fatal error: No ObservableObject of type Store<AppState, AppAction, World> found. A View.environmentObject(_:) for Store<AppState, AppAction, World> may be missing as an ancestor of this view.: file SwiftUI, line 0
2020-04-05 17:40:38.374178+0200 Recipes[3256:60476] Fatal error: No ObservableObject of type Store<AppState, AppAction, World> found. A View.environmentObject(_:) for Store<AppState, AppAction, World> may be missing as an ancestor of this view.: file SwiftUI, line 0

Do you know maybe what is causing the problem?

@mecid
Copy link
Owner

mecid commented Apr 5, 2020

@sm0nster Hi, could you please show me code that raises the error? Usually, we have this error when forget to pass EnvironmentObject.

@sm0nster
Copy link
Author

sm0nster commented Apr 5, 2020

Recipes/Features/Recipes/RecipesContainerView.swift:16:

private var recipes: [Recipe] {
        store.state.recipes.compactMap {
            store.state.allRecipes[$0]
        }
}

Sorry I didn't attach it earlier but I'm using AppCode, and this showed up after I have run it in Xcode.

@mecid
Copy link
Owner

mecid commented Apr 6, 2020

@sm0nster do you have added @EnvironmentObject var store?

@sm0nster
Copy link
Author

sm0nster commented Apr 6, 2020

@mecid I haven't changed anything it's just cloned repo

@mecid
Copy link
Owner

mecid commented Apr 6, 2020

@sm0nster I've just tried to clone the repo and it worked normally. Could you please try again?

@sm0nster
Copy link
Author

sm0nster commented Apr 6, 2020

@mecid I've cloned the repo again, run it and first, when I tapped "breakfast" it opened details controller with infinite loader, I tapped "back" and now when I'm trying to tap any meal type I get same error :/

@mecid
Copy link
Owner

mecid commented Apr 6, 2020

@sm0nster that's really strange because I can't reproduce the error.

@panckreous
Copy link

Hi,
I may be experiencing the same issue. I tap Breakfast (or any category) and the next screen just hangs. Repo is freshly cloned. I also tried creating my own api creds at edamam.com in case that was the issue, but that didnt help. Perhaps the fetch request isnt completing and causing an issue? I'm still getting familiar with Combine and Xcode debugging unfortunately, hence no solution and pr.

Xcode Version 11.4 (11E146)

Any ideas? Or additional info I can provide?

@mecid
Copy link
Owner

mecid commented Apr 21, 2020

@panckreous @sm0nster try to switch the filter to vegan recipes.

@panckreous
Copy link

confirmed working as expected with Vegan and Vegetarian.

@mecid mecid closed this as completed Apr 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants