Michael Long
May 3, 2021

--

In order to make a NavigationLink it needs a destination parameter, in your case view B. An instance of that view (struct) will be created and passed to NavigationLink each and every time the body of view A is evaluated. (Which can happen a lot.)

This is normal, and how SwiftUI works.

As such, note that you shouldn't be doing any heavy lifting on intialization of view B.

Wrote this one just for you:

https://michaellong.medium.com/swiftui-navigationlink-does-what-67947249bd8c

--

--

Michael Long
Michael Long

Written by Michael Long

I write about Apple, Swift, and SwiftUI in particular, and technology in general. I'm also a Lead iOS Engineer at InRhythm, a modern digital consulting firm.

No responses yet