Replies: 2 comments 2 replies
|
Hi @konrain, You can always construct a binding from scratch that sends actions under the hood rathe than performing mutations: ForEach(0..<viewStore.items.count, id: \.self) { index in
Stepper(
value: viewStore.binding(
get: { viewStore.items[index].value },
set: { viewStore.send(.changeValue(index, $0)) }
)
)
}You can also use the ForEachStore(
store.scope(state: \.items, action: AppAction.changeValue),
id: \.self
) { indexedStore in
WithViewStore(indexedStore) { indexedViewStore in
Stepper(
value: indexedViewStore(
get: { $0 },
send: StepperAction.changeValue
)
)
}
}This is only a sketch. For more info on how And finally, there's a chance that the |
0 replies
|
Also I just transferred this to our GitHub Discussions as it's more appropriate there. |
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
There does not seem to be a way to implement a stepper if the state value is an Array. Because the index cannot be passed when using a binding.
View
Reducer:
Workaround would be to use onIncrement & onDecrement, but docs indicate that is not possiable.
"If you create a
Steppervia theStepper.init(onIncrement:onDecrement:label:)initializerinside a
WithViewStoreit will behave erratically."Environment
All reactions