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 |
Beta Was this translation helpful? Give feedback.
-
Also I just transferred this to our GitHub Discussions as it's more appropriate there. |
Beta Was this translation helpful? Give feedback.
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
Stepper
via theStepper.init(onIncrement:onDecrement:label:)
initializerinside a
WithViewStore
it will behave erratically."Environment
Beta Was this translation helpful? Give feedback.
All reactions