Closed zhangpeibj01 closed 5 months ago
I logged state.todos
and there were no identical ids.
@zhangpeibj01 In the upgrade guide we note that the 1:1 migration requires you to explicitly select the id
from store state, otherwise ForEach
will take the child store's object identifier:
So you should update your code for a true comparison:
ForEach(
- store.scope(state: \.tasks, action: \.tasks)
+ store.scope(state: \.tasks, action: \.tasks), id: \.state.id
) { store in
SingleTaskView(store: store)
}
I'm going to convert this to a discussion since it doesn't appear to be a bug with the library, but if you do think you've encountered a bug, please provide a sample project that reproduces the issue. Without it we won't be able to troubleshoot the problem.
Description
I have studied the latest code of ToDos and tried to improve my project. But the unexpected issue occured. I am not sure if I did something wrong. I replace
Array<Task>
withIdentifiedArrayOf<Task>
and replacewith
Then the issue occured.
Checklist
main
branch of this package.Expected behavior
Can someone help me, Thanks
Actual behavior
ForEach<_StoreCollection<String, State, Action>, ObjectIdentifier, SingleTaskView>: the ID ObjectIdentifier(0x0000600003fe8b40) occurs multiple times within the collection, this will give undefined results!
Steps to reproduce
I tried to reassgin the value of state.todos.
The Composable Architecture version information
1.10.0
Destination operating system
macos 14.3
Xcode version information
Version 15.2 (15C500b)
Swift Compiler version information