Skip to content

Seeking Feedback on Reusable TCA SwiftUI Search Field Component #3515

Answered by mbrandonw
EvgenySai asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @EvgenySai, there are a few ways this can be improved. First, you don't need to make your view generic over the reducer, it can just be generic over the state and actions:

struct SearchField<State, Action>: View
where State: ObservableState, Action: BindableAction, Action.State == State {
  @Perception.Bindable var store: Store<State, Action>}

But more significantly, I would encourage you to reconsider whether such a simple reusable component needs to have any TCA in it at all. We never encourage adding TCA to every component throughout an entire app. There is a time and place for TCA, and typically it is at the level of a complex feature. This is where one gets the benefits of TC…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@EvgenySai
Comment options

Answer selected by EvgenySai
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants