Bug in iOS 16.1 NavigationLinks #1600
-
DescriptionWhen you use an NavigationLink inside another View that was opened with an NavigationLink, the isActive Bool sends false and the View goes back after it's been opened. Here a video of the Bug: What makes the Bug interesting for TCA is that this only happens when i use the TCA Architecture, but not when i use NavigationLinks with destination and label (without isActive) the bug disappears. Here is a example project: Checklist
Expected behaviorDescribed in description. Actual behaviorDescribed in description. Steps to reproduce
The Composable Architecture version information0.44.1 Destination operating systemiOS 16.1 Xcode version information14.1 Swift Compiler version informationswift-driver version: 1.62.15 Apple Swift version 5.7.1 (swiftlang-5.7.1.135.3 clang-1400.0.29.51)
Target: arm64-apple-macosx13.0 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
@tkoehlerlg |
Beta Was this translation helpful? Give feedback.
-
@tkoehlerlg Actually, this appears to be an issue of observing too much state. Your app is using the deprecated version of WithViewStore(store) { viewStore in This observes too much state at each layer, which can expose bugs in SwiftUI that become more common in applications that have a lot of state to observe, in this case a vanilla SwiftUI bug with navigation. TCA comes with tools that you can use to work around these bugs, though. In this case you can use the As a side note, in addition to using the soft-deprecated version of I'm going to convert this to a discussion now, since it's not a bug with the library, but instead a common SwiftUI bug that we have tools to work around. |
Beta Was this translation helpful? Give feedback.
-
Wow! Thank you so much @stephencelis, that worked! I will use this to optimise my apps from now on. And for the AnyReducer .. ähm .. swift suggested me this and i not really thought about it. But I will look in the new |
Beta Was this translation helpful? Give feedback.
@tkoehlerlg Actually, this appears to be an issue of observing too much state. Your app is using the deprecated version of
WithViewStore
that doesn't have anobserve
parameter at each layer:This observes too much state at each layer, which can expose bugs in SwiftUI that become more common in applications that have a lot of state to observe, in this case a vanilla SwiftUI bug with navigation. TCA comes with tools that you can use to work around these bugs, though. In this case you can use the
observe
parameter to chip away at just the state a local view cares about. For more info, see our article on view store performance:https://pointfreeco.github.io…