title: Load different data by ID in the same View
body: <p>I want to load different data in the same View using an ObservableObject with an Index.</p>
  <p>As you can see in the simple demo example attached when I go through the views changing the id in order to load different data it works.</p>
  <p>But when in any point I change another data from another observable object (in this case <em>AnotherObservable</em>) then my view breaks and any data is found at all.</p>
  <p>Navigation works...</p>
  <p><a href="https://i.stack.imgur.com/yXAAt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yXAAt.png" alt="Works" /></a></p>
  <p>Once I press Change Title button...</p>
  <p><a href="https://i.stack.imgur.com/BguEr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BguEr.png" alt="Issue" /></a></p>
  <p>To test de issue just simple copy and paste the code and navigate through the data with the <em><strong>&lt;- -&gt;</strong></em> and then press <em><strong>Change title</strong></em> button</p>
  <pre><code>class DemoItemsLoader: ObservableObject {
      @Published var items = [1, 2, 3, 4]
  }
  
  class DemoArticleLoader: ObservableObject {
      @Published var items = [1 : &quot;One&quot;, 2 : &quot;Two&quot; , 3 : &quot;Three&quot;, 4 : &quot;Four&quot;]
      @Published var realData: String?
  
      func loadItemForID(id: Int) {
          realData = items[id] ?? &quot;Not found&quot;
      }
  }
  class AnotherObservable: ObservableObject {
      @Published var title: String = &quot;Title&quot;
  }
  
  
  struct Class1: View {
      @StateObject var anotherObservable = AnotherObservable()
      @StateObject var itemsLoader = DemoItemsLoader()
      var body: some View {
          NavigationView{
              VStack {
                  ForEach(itemsLoader.items, id: \.self) { item in
                      NavigationLink(
                          destination: Class2(anotherObservable: anotherObservable, articleLoader: DemoArticleLoader(), id: item)) {
                          Text(&quot;\(item)&quot;)
                      }
                  }
              }
          }
      }
  }
  
  struct Class2: View {
      @ObservedObject var anotherObservable: AnotherObservable
      @ObservedObject var articleLoader: DemoArticleLoader
      @State var id: Int
  
      var body: some View {
          VStack {
              Text(anotherObservable.title)
              Text(articleLoader.realData ?? &quot;Not found&quot;)
              HStack {
                  Spacer()
                  Button(action: {
                      if id &gt; 1 {
                          id = id - 1
                          articleLoader.loadItemForID(id: id)
                      }
                  }) {
                      Text(&quot;&lt;-&quot;)
                  }
                  Button(action: {
                      if id &lt; articleLoader.items.count {
                          id = id + 1
                          articleLoader.loadItemForID(id: id)
                      }
  
                  }) {
                      Text(&quot;-&gt;&quot;)
                  }
                  Button(action: {
                      anotherObservable.title = &quot;Another Title&quot;
                  }) {
                      Text(&quot;Change title&quot;)
                  }
                  Spacer()
              }
          }
          .onAppear { articleLoader.loadItemForID(id: id)}
      }
  }
  </code></pre>