simibac / ConfettiSwiftUI

SwiftUI Package for Configurable Confetti Animation 🎉
MIT License
1.71k stars 117 forks source link

Dynamically added text #47

Open frantischek opened 9 months ago

frantischek commented 9 months ago

I try to add an emoji which is recieved by an APN:

    @State private var receivedEmoji: String = "🎉"
    @State private var cannonEmoji: String = "🥥"
[...]
        VStack {
[...]
        .onChange(of: receivedEmoji) { newValue in
            animationCounter += 1
            cannonEmoji = newValue
            print("Emoji \(cannonEmoji)") <--- here it prints the recieved emoji and not the initialized one.
        }
       // .animation(.easeInOut(duration: 0.5), value: sortedActions)
        ConfettiCannon(counter: $animationCounter ,confettis: [.text(cannonEmoji)], confettiSize: 20)

.text(cannonEmoji)allways fires the coconut (🥥) - which looks also great. :D

How can I solve this?