// // FactsView.swift // Facts // import SwiftUI import Foundation import ComposableArchitecture public struct FactsView: View { let store: StoreOf public init(store: StoreOf) { self.store = store } public var body: some View { VStack { switch store.state.mode { case .notLoaded: EmptyView() case .loading: ProgressView() case let .loaded(facts): List(facts, id: \.self) { fact in Text(fact) } case let .error(error): Text(error.localizedDescription) } } .onAppear { store.send(.viewAppeared) } } } #Preview { FactsView(store: .init(initialState: FactsFeature.State()) { FactsFeature() }) }