title: Using @StateObject in iOS 14.0 while supporting iOS 13.0
body: <p>I need help finding the best way to support the new @StateObject in iOS 14.0 and still supporting some alternative in iOS 13.0. Admittedly, I do not know what is the best approach in iOS 13.0. Below is what I currently have.</p>
  <p>Does anyone have ideas on a better approach?</p>
  <pre><code>struct HomeView: View {
      let viewModel: HomeViewModel
  
      var body: some View {
          if #available(iOS 14, *) {
              HomeViewWrapper(viewModel: viewModel)
          } else {
              CompatibleHomeViewWrapper(viewModel: viewModel)
          }
      }
  }
  
  @available(iOS 14, *)
  private struct HomeViewWrapper: View {
      @StateObject var viewModel: HomeViewModel
  
      var body: some View {
          CompatibleHomeView(viewModel: viewModel)
      }
  }
  
  private struct CompatibleHomeViewWrapper: View {
      @State var viewModel: HomeViewModel
  
      var body: some View {
          CompatibleHomeView(viewModel: viewModel)
      }
  }
  
  struct CompatibleHomeView: View {
      @ObservedObject var viewModel: HomeViewModel
  
      var body: some View {
          Text(viewModel.someRandomName)
      }
  }
  </code></pre>