I'm trying to make work together a ForEachStore (to iterate the grid cells items stores) inside a LazyVGrid.
But I don't know if the LazyGrid feature is to work with the composable framework because it throws an error when running (and the preview is not working too)
Hi @brunobasas, thanks for letting us know that there might be potential trouble with our ForEachStore and the new lazy views in SwiftUI. We haven't had too much time to play with lazy views, so good to catch this early!
Can you share a bit more code so that we can reproduce the error locally? I was able to get a very simple LazyVStack working with the following code:
import ComposableArchitecture
struct Row: Equatable, Identifiable {
let id = UUID()
}
struct LazyView: View {
let store = Store<[Row], Never>(
initialState: (1...1_000).map { _ in Row() },
reducer: .empty,
environment: ()
)
var body: some View {
ScrollView {
LazyVStack {
ForEachStore(
self.store.scope(state: { $0 }, action: { _ in fatalError() }),
content: RowView.init(store:)
)
}
}
}
}
struct RowView: View {
let store: Store<Row, Never>
var body: some View {
WithViewStore(self.store) { viewStore in
Text("Hi \(viewStore.id)")
}
}
}
Is there anything you are doing in your code that is substantially different from what is above?