-
Hello everyone, I am curious, why my code, which is identical (if I haven't made any mistake) to the one from the tutorial, works differently. Many thanks for any suggestions. Here is my code: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @jmgawecki, thanks for the question. This is actually due to a change in SwiftUI between iOS 13 and 14. In iOS 13, SwiftUI would implicitly animate a lot of things for you (such as rows in a There are a few ways you can get animation back. You could tack on a List {
ForEachStore(
self.store.scope(state: \.todos, action: AppAction.todo(index:action:)),
content: TodoView.init(store:)
)
}
.animation() This will make it so that the Alternatively, you can be a little bit more focused when the list animates by using animated schedulers, which is a concept we discussed in this collection of episodes. You can do this by using the return Effect(value: AppAction.todoDelayCompleted)
.delay(for: 1, scheduler: /*➡️*/ DispatchQueue.main.animation() /*⬅️*/)
.eraseToEffect()
.cancellable(id: CancelDelayId(), cancelInFlight: true) We should probably add a correction to the episode to explain this behavior to our viewers. We'll try to do that soon. |
Beta Was this translation helpful? Give feedback.
Hi @jmgawecki, thanks for the question. This is actually due to a change in SwiftUI between iOS 13 and 14. In iOS 13, SwiftUI would implicitly animate a lot of things for you (such as rows in a
List
) without you needing to do anything in code. But in iOS 14 SwiftUI started requiring you to be more explicit with animations.There are a few ways you can get animation back. You could tack on a
.animation
view modifier to the list:This will make it so that the
List
always animates its contents.Alternatively, you can be a little bit more fo…