ForEachStore Performance! #853
Answered
by
abdelmajidrajad
abdelmajidrajad
asked this question in
Q&A
-
Actually scoping in ViewStore reduce the view reloads into its scoped variables but sometimes we need to apply a viewModifier without reloading the view itself. Problem example: GeometryReader { proxy in
WithViewStore(store.scope(state: ViewState.init)) { viewStore in
LazyVGrid(
columns: Array(
repeating: .init(.fixed(viewStore.rowLength),
spacing: viewStore.spacing),
count: viewStore.rows),
spacing: viewStore.spacing
) {
ForEachStore(
store.scope(
state: \.boxes,
action: BoxAction.cell(id:action:)
)
) {
PageRowView(store: $0)
.frame(
width: viewStore.rowLength,
height: viewStore.rowLength
)
}
}.frame(width: viewStore.width, height: viewStore.height)
.onAppear {
viewStore.send(.drawRect(proxy.frame(in: .boxSpace)))
}
}
}.clipShape(vs.clipPath) // we want to call this without triggering the forEach
.contentShape(vs.clipPath)
}.drawingGroup()```
How we can get rid of ForeEachStore children body calls ? |
Beta Was this translation helpful? Give feedback.
Answered by
abdelmajidrajad
Oct 14, 2021
Replies: 1 comment
-
I ended moving GeometryReader view to a subview then conclude a rule: |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
abdelmajidrajad
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I ended moving GeometryReader view to a subview then conclude a rule:
Any View that you want to prevent to compute should be into its own body.