Closed sisoje closed 5 months ago
I found the workaround, instead of:
ViewHosting.host(
view: model.modelContainer(for: Item.self, inMemory: true)
)
I use this
ViewHosting.host(
view: model.environment(\.modelContext, context)
)
I am using SwiftData and writing some tests. I noticed a runtime warning:
Accessing StateObject's object without being installed on a View. This will create a new instance each time.
The test is:
Note that the view is completely empty. Only by applying modifier
.modelContainer
the warning shows.Here is the warning:![Screenshot 2023-11-13 at 13 13 18](https://github.com/nalexn/ViewInspector/assets/3493524/9880efe1-be95-40aa-860e-bc6ca1eae3a6)