Comments (5)
It looks like you’re missing WithPerceptionTracking inside your navigation stack’s destination closure, so iOS 16 cannot detect changes to the state inside the presented view.
from swift-composable-architecture.
It looks like you’re missing WithPerceptionTracking inside your navigation stack’s destination closure, so iOS 16 cannot detect changes to the state inside the presented view.
Thank you for your response. Based on your suggestion, I wrapped the navigation stack's destination closure with WithPerceptionTracking. However, there have been no changes.
I tried a different approach. I replaced NavigationStack with NavigationStackStore, and then it worked correctly on iOS16. I think there might be a slight difference between NavigationStack and NavigationStackStore.
NavigationStackStore(self.store.scope(state: \.path, action: \.path)) {
EmptyView()
} destination: { store in
SwitchStore(store) {
switch $0 {
case .demo:
CaseLet(/RootStore.Path.State.demo,
action: RootStore.Path.Action.demo) { _store in
DemoView(store: _store)
}
}
}
}
from swift-composable-architecture.
@tsudo-kiroru the purple warnings are your clue that you're definitely missing a WithPerceptionTracking
somewhere, that's why your view is not responding to state changes on iOS 16. Try expanding the backtrace of that error.
from swift-composable-architecture.
@tsudo-kiroru the purple warnings are your clue that you're definitely missing a
WithPerceptionTracking
somewhere, that's why your view is not responding to state changes on iOS 16. Try expanding the backtrace of that error.
@lukeredpath
Thank you for your reply. Based on your suggestion, I fixed my code as following below. I wrapped NavigationStack destination scope with WithPerceptionTracking. Then, the purple warnings disappeared. So I guess that state must be tracked.
NavigationStack(path: $store.scope(state: \.path, action: \.path)
) {
EmptyView()
} destination: { destination in
WithPerceptionTracking {
let scope = destination.case
switch scope {
case let .demo(store):
DemoView(store: store)
}
}
}
However, the navigation feature does not work correctly on iOS 16. There seems to be a difference between iOS 16 and iOS 17(As same as capturing movie).
It becomes harder to find the problem because no errors or warnings occur.
from swift-composable-architecture.
Hi @tsudo-kiroru, I believe this is just a problem with vanilla SwiftUI in general. The following code snippet works fine in iOS 17, but does not work in iOS 16:
class Model: ObservableObject {
@Published var values: [Int] = []
}
struct ParentView: View {
@StateObject var model = Model()
var body: some View {
Form {
Button("Open") {
model.values.append(1)
}
.sheet(
isPresented: Binding(
get: { !model.values.isEmpty },
set: { if !$0 { model.values = [] } }
)
) {
NavigationStack(path: $model.values) {
EmptyView()
.navigationDestination(for: Int.self) { int in
Form {
Button("Push") {
model.values.append(.random(in: 0...1_000))
}
}
}
}
}
}
}
}
Since this is not a TCA issue I am going to convert it to a discussion, but please feel free to continue the conversation over there.
from swift-composable-architecture.
Related Issues (20)
- Unnecessary "observe" warning HOT 1
- .send(.presentCustomAlert, animation: .none) method does not work when present / dismiss fullScreenCover HOT 1
- Missing an expected key: 'NSPrivacyCollectedDataTypes' HOT 7
- TCA release 1.10.0 and Swift Perception 1.1.6 mismatch HOT 1
- @Shared crashes app
- Dismiss more than one feature HOT 2
- TCA 1.7.0 minimum version error iOS15 HOT 9
- Key path cannot refer to static member '....' Error HOT 1
- TCA holds on to state for longer than expected HOT 1
- Nested enum reducer error: cannot be constructed because it has no accessible initializers HOT 3
- ForEach<_StoreCollection<String, State, Action>, ObjectIdentifier, SingleTaskView>: the ID ObjectIdentifier(0x0000600003fe8b40) occurs multiple times within the collection, this will give undefined results! HOT 2
- Exhaustive testing @Shared variable mutating before action received HOT 2
- Extra Perception Warning HOT 1
- Non-main thread warning when calling using .refreshable from child @ViewBuilder property HOT 1
- Focus state doesn't work as described in the Building SyncUps Tutorial
- UUID creation not working as described in the SyncUps Tutorial HOT 2
- FileStorage persistence sometimes doesn't save data to disk. HOT 1
- Some texts not appearing correctly: body-8lumc
- SharedState with UserDefaults(suiteName:) not working properly HOT 3
- NSLock Memory leaks HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swift-composable-architecture.