1

FolderRowのfolderLowArrayをAnotherViewに遷移時にanotherViewLowArrayに代入したいのですが、以下のコードでエラーが出ます。

FolderRowにfolderLowArrayは入っているはずなのですが、なぜでしょうか。

エラー:

Cannot find 'folderLowArray' in scope

現状のコード:

struct ContentView: View {
    let fruits = ["りんご", "オレンジ", "バナナ"]
    var body: some View {
    NavigationView {
        List {
            Section {
                Text("大根")
                Text("キャベツ")
                Text("じゃがいも")
            } header: {
                Text("やさい")
            }
            Section {
                ForEach(0 ..< fruits.count) { index in
                    NavigationLink(destination: {AnotherView(anotherViewLowArray: folderLowArray)}, label: {FolderRow(folderLowArray: folderLowArray, folderLowPicture: "trash", folderLowName: "trash")})
                }
            } header: {
                Text("くだもの")
            }
        }
    }
}
}

struct AnotherView: View { 
@State var anotherViewLowArray = [""]
var body: some View {
List{Section(header: Text("テキスト")){ForEach(0..<anotherViewLowArray.count) { index in NavigationLink(destination: SecondView(), label: {Image(systemName: "gear")})}}}
}}

struct FolderRow: View {
    var folderLowArray: [String] = []
    var folderLowPicture = "trash"
    var folderLowName: String = "pin"
    var body: some View {
        HStack{
            Image(systemName: folderLowPicture)
            Text(folderLowName)
            Text("\(folderLowArray.count)")
        }
    }}

0

この質問に回答するには、ログインする必要があります。

のタグが付いた他の質問を参照する。