Avatar
こんな感じで実装用のビューを分けてやれば、 @Environment でDIを可能にしつつ、ViewStateを持つというのは一応できそうです。Observationを使う方なら。 struct UserView: View { let id: User.ID @Environment(UserStore.self) var userStore var body: some View { UserStateView(state: UserViewState(userStore: userStore, id: id)) } } struct UserStateView: View { let state: UserViewState var body: some View { VStack { Text(state.user?.name ?? "User Name") .redacted(reason: state.user == nil ? .placeholder : []) .font(.title) ...