Pass a binding variable from one state to another in swiftui

449 Views Asked by At

I am new to SwiftUI and TCA (the composable architecture) and I am having troubles passing a binding var in one state from one view to another. Here's what I'm doing:

In PlaceView I have the following state:

struct PlaceStore: ReducerProtocol {
    struct State: Equatable { 
        var placeSelected: Place?
        var presentingCreatePlace: Bool = false
    }
//etc

}

And I have a CreatePlaceView that is presented as sheet from PlaceView when presentingCreatePlace is true through a button tap.

struct CreatePlaceStore: ReducerProtocol {
    struct State: Equatable {      
        @BindingState var placeSelected: Place?        
    }
  }

I want to pass the placeSelected from PlaceView to CreatePlaceStore as a binding but when I send it through the init of the store, it says that is not expecting a binding. How can I do it?

0

There are 0 best solutions below