-1

Navigating from view A to view B, i m passing a var show . View A isn t visible anymore .

I need to have a @State var stateShow whose initial value is the same as value show passed to B from A .

How to do it without using onAppear ? Thanx

struct B : View {

    public var show:Bool
    
    @State private stateShow : Bool
    
    init (_ show : Bool){
        self.show = show
    }
    
}
vadian
  • 274,689
  • 30
  • 353
  • 361
it75
  • 125
  • 10

1 Answers1

0

init (_ show : Bool){

    self.show = show
    _stateShow = State(initialValue: show)
}

Answer credited to vadian ,another similar question was asked with a similar answer but slightly different conditions :

it75
  • 125
  • 10