Make your App faster using LazyVStack and LazyHStack in SwiftUI

Build an App Store component replica to learn how LazyStacks can optimize your app performance

Finsi Ennes
The Startup

--

A lot of cool features were added to SwiftUI with iOS 14, one of them are the lazy stacks. In this article you will see the advantages of using it. We will learn about how this stacks works, how they can improve our app performance and the situations where they are useful.

Regular stack issues

Before including the concept of laziness on this components, SwiftUI just provided VStack and HStack. Both load all their content once the view is initialized. This is not a problem in light apps but a different situations occurs when the amount of data starts growing.

Let’s think in apps such as Amazon or Netflix. They have complex views which contain several types of grids filled with tons of products and information:

Use constantly regular stacks in scenarios like these can end up causing performance and memory issues.

Lazy stack solution

--

--

Finsi Ennes
The Startup

iOS Developer. Passionate about coding and UX design. For more content, you can follow me on Instagram @finsi.code