thank you bruh, you da best. Theese short videos me like su much ! 🔥
@rahuljamba58468 ай бұрын
Thanks for sharing your knowledge !! keep it up
@marceljaeger8 ай бұрын
Nice video and yeah sometimes you may need to update a view body programatically. But you need to be carefully with changing the identity of a view. When you change an identity of a view. The whole view hierarchy of that view will be created new and that can cause performance issues. Additionally the State properties of Subviews of the HStack will be created new, because the identity changed. So I think a better way may be this: This causes an update of the body of ContentView but not for all Subviews of the HStack if the View values of those Subviews is not different. An other way can be to change the identity of the Color in background without the If statement. struct ContentView: View { @State var value: Bool = true var body: some View { let _ = Self._printChanges() HStack { Button { value.toggle() } label: { Text("Refresh") } //Other sub views } .background { if isTrue { Color.black.opacity(0) }else { Color.black.opacity(0) } } } }
@30guarino8 ай бұрын
Flo, Was wondering if you can do a video or provide any documentation on how in a chat message view have the last message scroll up above the keyboard when it APPEARS?....Any help will be greatly appreciated
@FloWritesCode8 ай бұрын
You should be able to use ScrollViewReader to scroll programmatically - I have a video on that API.
@tylerwatt56518 ай бұрын
I'd assume you could use .onAppear in place of the button right?
@FloWritesCode8 ай бұрын
Yup, depending on your use case.
@markaurelius618 ай бұрын
You can keep the code tighter by putting the id change after the button: Button("Refresh") { (internalState += 1) } .id(internalState)
@FloWritesCode8 ай бұрын
Yup, playing around with the position of the id modifier probably makes sense 👍
@0xLarx8 ай бұрын
Where are you mate 😂 last video 3 months ago
@FloWritesCode8 ай бұрын
Been busy with real life stuff! Is there anything you'd like to see on the channel after this break? Thanks for sticking around!
@HomesteadAce8 ай бұрын
Wasn't the whole point of this view to not use @state? You should have removed it at the end to show that the refresh happens because of the id and not the state change?
@markaurelius618 ай бұрын
If internalState is not declared with @State, you can't change it in the button event
@SHOLINGER8 ай бұрын
@HomesteadAce no , the whole point , because the struct is immutable , so @state property wrapper is definitely needed here !!