Better Programming

Advice for programmers.

Member-only story

Exploring Rendering in SwiftUI

Riccardo Cipolleschi
Better Programming
Published in
4 min readSep 11, 2022

--

Photo by Viktor Forgacs on Unsplash

One of the amazing aspects of the Software engineering profession is that you never stop learning. You are exposed every day to different technologies: learning their basic concepts is one of the things that I personally like the most.

One of the most important skills to learn new technologies is the ability to recognize patterns and similarities. This allows you to reason about a new technology even if you don’t use it every day.

A week ago, a colleague of mine sent me this article on React rendering. I don’t use React every day, but I am familiar with its basic concepts and I couldn’t notice how similar SwiftUI it is. While reading the article, I was surprised to see that React re-renders when the state of a Component changes and not when its props do.

So, my curiosity tingled: what does SwiftUI do? When does it re-render its components? I created a small project to try and understand that and today I want to share my process and my findings.

Recreating the App

The first step I took was to reproduce the same situation of the one presented in the article. I created a new SwiftUI project with the same initial components:

  • The BigCountNumber

--

--

Riccardo Cipolleschi
Riccardo Cipolleschi

Written by Riccardo Cipolleschi

Hey there, I’m Riccardo. Software engineer at Meta. I have a passion for iOS and I love to share my knowledge with others.

Responses (2)