-
Notifications
You must be signed in to change notification settings - Fork 78
Closed
Description
Description
import Perception
import SwiftUI
@Perceptible
class ColorModel {
var color: Color = .clear
}
struct ContentView: View {
@State var model = ColorModel()
var body: some View {
let _ = print("\(Self.self): tracked change.")
WithPerceptionTracking {
VStack {
ForEach(0 ... 3, id: \.self) { _ in
// WithPerceptionTracking {
model.color
// }
}
}
}
}
}
#Preview {
ContentView()
}If I comment out the above content, I will get the following runtime warning:
Perceptible state was accessed but is not being tracked. Track changes to state by wrapping your view in a 'WithPerceptionTracking' view.
Checklist
- I have determined whether this bug is also reproducible in a vanilla SwiftUI project.
- If possible, I've reproduced the issue using the
mainbranch of this package. - This issue hasn't been addressed in an existing GitHub issue or discussion.
Expected behavior
I expect i can put WithPerceptionTracking outside ForEach
Actual behavior
We must put WithPerceptionTracking in each loop
Steps to reproduce
No response
Perception version information
No response
Destination operating system
No response
Xcode version information
No response
Swift Compiler version information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels