

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

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

**エラー:**

[code]

    Cannot find 'folderLowArray' in scope
    
[/code]

**現状のコード:**

[code]

    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)")
            }
        }}
    
[/code]


CC BY-SA 4.0
2023-03-09T03:04:04.647
94110
2023-03-09T05:12:49.740
2023-03-09T05:12:49.740
3060
39481
question
swiftui
任意の配列を表示したい