ForEach loop works unanimously

When I try to iterate over Identifiable struct var with foreach loop nested with other foreach lop taking structs attribute say array and representing it as button in ui then only last iterated item from array is enabled. Code struct Player { let id : Int var birth: Piece }

struct Piece { let id: Int var moves: Int }

ForEach($players, id: .id) { player in let pl: Player = player.wrappedValue ForEach(pl.birth, id: .id) { bp in OverlayBirthPieces(cur_pl: player, movingpiece: .constant(bp), color: pl.color) } }

I want all the pl.birth item (pieces on Ludo board) to be enabled if player.chance == true. but only last birthplace is getting enabled

When you post code, please edit it with Code foramatter tool.

struct Player {
    let id : Int
    var birth: Piece
}

struct Piece {
    let id: Int
    var moves: Int
}
ForEach($players, id: .id) { player in
    let pl: Player = player.wrappedValue    ForEach(pl.birth, id: .id) { bp in
        OverlayBirthPieces(cur_pl: player, movingpiece: .constant(bp), color: pl.color)
    }
}

And provide complete code so that we can try to reproduce. You don't even show where the buttons are !

I am extremely sorry but the overlayBirthpieces View contains a single button. I have just signup yesterday so I am unable to format code

      Label:{
           Image(systemName: “mappin”)
}
ForEach loop works unanimously
 
 
Q