ScrollViewreader multiple ScrollTo in multiple Foreach

Hello I have an issue, I can't make many .scrollTo() in my code: (I'm French sorry for my bad english)

Code Block
else if index == 1 {
withAnimation {
                value.scrollTo(topID)
         }
}


my issue is in value.scrollTo(topID) I tried to implement 6 of them in 3 differents foreach and The compiler doesn't compile but if I remove the value.scrollTo(topID) of one of the Foreach it compile

Code Block
else if wichView.SelectedView == 5 {
                HStack {
                  ForEach(1..<6) { index in
                    Spacer()
                    Button(action: {
                      if index == 3 {
                        withAnimation() {
                          wichView.SelectedView = 1
                          wichView.carouselLocation = 0
                        }
                        value.scrollTo(topID)
                      }
                      else if index == 1 {
                        withAnimation {
                          value.scrollTo(topID)
                        }
                      }
                    },
                    label: {
                      Image("IPPV5_TABBITEM\(index)")
                        .resizable()
                        .aspectRatio(contentMode: .fit)
                        .frame(width: 40,
                            height: 40)
                    })
                  }
                  Spacer()
                }
                .padding(.bottom, -10)
                .frame(width: size.width,
                    height: 35)
              }
              else if wichView.SelectedView == 6 {
                HStack(spacing: size.width/3 - 10) {
                  Button(action: {
                    withAnimation {
                      value.scrollTo(topID)
                    }
                  },
                  label: {
                    Image("IPPV6-TABITEM1")
                      .resizable()
                      .aspectRatio(contentMode: .fit)
                      .frame(width: 40,
                          height: 40)
                     
                  })
                   
                  Button(action: {
                    wichView.SelectedView = 1
                    wichView.carouselLocation = 0
                    value.scrollTo(topID)
                  },
                  label: {
                    Image("IPPV6-TABITEM2")
                      .resizable()
                      .aspectRatio(contentMode: .fit)
                      .frame(width: 40,
                          height: 40)
                  })
                  Spacer()
                }
                .padding(.bottom, -10)
                .frame(width: size.width - 40,
                    height: 35)
              }
              else if wichView.SelectedView == 8 {
                IPPV8TabItem
              }
              else if wichView.SelectedView == 9 {
                HStack {
                  ForEach(1..<6) { index in
                    Spacer()
                    Button(action: {
                      if index == 3 {
                        withAnimation {
                          wichView.SelectedView = 1
                        }
                        wichView.carouselLocation = 0
//                        withAnimation {
//                          value.scrollTo(topID)
//                        }
                      }
                      else if index == 1 {
//                        withAnimation {
//                          value.scrollTo(topID)
//                        }
                      }
                    },
                    label: {
                      Image("IPPV9-\(index)")
                        .resizable()
                        .aspectRatio(contentMode: .fit)
                    })
                  }
                  Spacer()
                }
                .frame(width: size.width,
                    height: 40)
              }

This is Part of my code (all is in a ScrollView who is in a Scrollviewreader who is in a Vstack who is in a Zstack)

This code work fine and compile because I commented the .scrollTo() of one of the Foreach if I decomment it will not compile.

Any help please?
if someone found this try to merge all your scrollTo in a Foreach (I merged the
Code Block
else if wichView.SelectedView == 5
and the
Code Block
else if wichView.SelectedView == 9
and it works but still don't know why it doesn't work with different conditions)
ScrollViewreader multiple ScrollTo in multiple Foreach
 
 
Q