At 21:40 in the video the following code is shown:
(sorry for the screenshot but this talk doesn't have code copy enabled)
Luca points out this results in new view and storage every time dayTime changes. Say you wanted to fix it so it doesn't create a new view and storage every time, how would you do that?
Like this maybe?
var body: some View {
let cr = CatRecorder()
if dayTime {
return cr.nightTimeStyle()
}
else {
return cr
}
}
But this code doesn't look very declarative. I've seen many struggle with applying modifiers conditionally (especially .hidden()) so thought I'd ask.