title: Why LazyVStack does not Works as Lazy View and it needs ScrollView to works?
body: <p>I have very simple code to testing <strong>Lazy</strong> loading Views, like in the code in down:</p>
  <p><em><strong>This is my Row:</strong></em></p>
  <pre><code>struct RectangleView: View {
      
      let index: Int
      
      var body: some View {
  
          print(&quot;rendering for: &quot; + String(describing: index))
  
          return Rectangle()
              .frame(height: 40, alignment: .center)
              .foregroundColor(.blue)
              .cornerRadius(10)
              .overlay(Text(String(index)).bold().foregroundColor(Color.white))
  
      }
      
  }
  </code></pre>
  <p>Here is the issue! if you just use <code>LazyVStack</code>, SwiftUI will load all the rows until last upper Range of <code>ForEach</code> which I do not understand this behavior! because this is <code>LazyVStack</code> <strong>Not</strong> <code>VStack</code> and I expect that <code>LazyVStack</code> take some consideration of laziness and not just rendering from down Range to upper Range!  How ever if I just add a <code>ScrollView</code> to the codes! <code>LazyVStack</code> start working as a Lazy View, and it stops rendering Views of <code>ForEach</code> from down Range to upper Range!</p>
  <p>So the question is here why <code>LazyVStack</code> needs ScrollView for working as a Lazy View?</p>
  <p>I am working on a <code>CustomScrollView</code> and I should give Lazy Contents for my <code>CustomScrollView</code> and I need LazyVStack for this job, So as I said before LazyVStack works with <code>ScrollView</code> and since I am working on a <code>CustomScrollView</code> then I am not using Apple <code>ScrollView</code>, in this case <code>LazyVStack</code> acts like a normal <code>VStack</code> and start rendering from down Range to upper Range! Why <code>LazyVStack</code> is acting like this? If I do not use <code>LazyVStack</code> the memory usage goes upper than 100 mb and with more advanced Row it reach easy over 200 mb and it is so laggy and unusable!</p>
  <p><strong>How can I be sure that, I am passing Lazy Content?</strong></p>
  <pre><code>struct ContentView: View {
  
      @State private var maxRange: Int = 2_000
  
      var body: some View {
  
          ScrollView { // Here: If you do not use ScrollView, LazyVStack would works as VStack!!! Why?
              
              LazyVStack {
  
                  ForEach(0...maxRange, id: \.self) { index in RectangleView(index: index) }
                  
              }
              .padding()
              
          }
  
      }
      
  }
  </code></pre>
  <hr />
  <p><em><strong>This is my CustomScrollView:</strong></em></p>
  <pre><code>struct CustomScrollView&lt;ViewType: View&gt;: View {
  
      let importedContent: () -&gt; ViewType
  
      var body: some View { return importedContent() }
  
  }
  </code></pre>
  <hr />
  <p><strong>Use case:</strong></p>
  <pre><code>struct ContentView: View {
  
      @State private var maxRange: Int = 2_000
  
      var body: some View {
  
          CustomScrollView { // Here: LazyVStack would works as VStack!!! Why?
              
              LazyVStack {
  
                  ForEach(0...maxRange, id: \.self) { index in RectangleView(index: index) }
                  
              }
              .padding()
              
          }
  
      }
      
  }
  </code></pre>