-
When I extract view content wrapped by Is it possible to improve it so that warnings are triggered? @Reducer
struct Content {
@ObservableState
struct State: Equatable {
var flag = false
}
enum Action {
case tapped
}
var body: some ReducerOf<Self> {
Reduce { state, action in
switch action {
case .tapped:
state.flag.toggle()
return .none
}
}
}
}
struct ContentView: View {
let store: StoreOf<Content>
var body: some View {
WithPerceptionTracking {
content
}
}
var content: some View {
GeometryReader { geometry in
VStack {
Button {
store.send(.tapped)
} label: {
Text("Tap!")
}
Text(store.flag ? "True" : "False")
}
}
}
} To make the above code work, I have to add @MainActor
var content: some View {
GeometryReader { geometry in
WithPerceptionTracking
VStack {
Button {
store.send(.tapped)
} label: {
Text("Tap!")
}
Text(store.flag ? "True" : "False")
}
}
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
takehilo
Mar 2, 2024
Replies: 1 comment
-
#45 fixed this. Thanks! |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
takehilo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#45 fixed this. Thanks!