Created
June 13, 2021 00:15
-
-
Save mhijack/fa6af1c0ac6b79404a8a40281558d958 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct BookList: View { | |
@ObservedObject var store = BookStore() // <- Change to @StateObject or create this else where to solve the issue | |
var body: some View { | |
List { | |
ForEach(store.books, id: \.name) { | |
Text($0.name) | |
} | |
} | |
} | |
} | |
class BookStore: ObservableObject { | |
@Published var books: [Book] = [Book(name: "The "Great Influenza)] | |
} | |
struct ContentView: View { | |
var body: some View { | |
NavigationView { | |
BookList() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment