-
I just upgraded a little project of mine to TCA 1.0.0 and now am having the issue of not being able to instantiate a I cannot see where a possible mistake of mine could be the root cause, but maybe I am just not seeing it? I created a minimal Reducer to show the issue: import ComposableArchitecture
import SwiftUI
struct SampleFeature: Reducer {
struct State: Equatable {}
enum Action {}
var body: some ReducerOf<Self> {
Reduce { state, action in
return .none
}
}
}
struct SampleFeatureView: View {
let store: StoreOf<SampleFeature>
var body: some View {
WithViewStore(store, observe: { $0 }) { viewStore in
Text("Hello, World!")
}
}
}
#Preview {
SampleFeatureView(
store: Store(
initialState: SampleFeature.State(),
reducer: SampleFeature()
)
)
} The errors Xcode is showing me down in the preview are:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Store now take a closure for the reducer arg like: |
Beta Was this translation helpful? Give feedback.
-
Oh, I totally overlooked this (even though watching episode 243 earlier). I can totally confirm that #Preview {
SampleFeatureView(
store: Store(
initialState: SampleFeature.State()) {
SampleFeature()
}
)
} works. I am also realizing that I have to improve reading (and understanding …) these error messages–with your much appreciated (and blazingly fast 🤯) reply I do understand, but I failed seeing it myself... Thanks for your help! |
Beta Was this translation helpful? Give feedback.
-
You mean something like this: let store = Store<ProjectListFeature.State, ProjectListFeature.Action>( … ) In this specific case, the error messages remain the same... |
Beta Was this translation helpful? Give feedback.
Store now take a closure for the reducer arg like:
reducer: { SampleFeature() }
; have a look at the third error message