Closed Rokas91 closed 8 months ago
Hi @Rokas91, this is mentioned in the migration guide for 1.7, but using ForEach
with a $store
binding uses the child stores for the identity of each row, not the identity of the state in the store. This means your scrollPosition
is a completely different type than the underlying identity of the ForEach
.
To fix you must use an explicit id
key path:
ForEach(
store.scope(state: \.items, action: \.items),
id: \.state.id
) { store in
}
Since this is not an issue with the library I am going to convert it to a discussion.
Description
Binding for
scrollPosition
is not working when usingForEach
, but it works usingForEachStore
.Checklist
main
branch of this package.Expected behavior
scrollPosition
should update binding attribute.Actual behavior
Binding attribute is not updated.
Steps to reproduce
Replace
ForEach
withForEachStore
and binding for scroll position will work.The Composable Architecture version information
1.8.2
Destination operating system
iOS 17.2
Xcode version information
15.2
Swift Compiler version information
No response