0

For navigation I am using the iOS 16 NavigationStack API. I keep my NavigationPath instance inside my view models as @Published instead of in the views with @State. When navigating between the different screen I get this output message Update NavigationAuthority bound path tried to update multiple times per frame.

I do not know what is causing this message to appear.

How do I get rid of it?

Edit: After playing around with my code I noticed that an .onAppear modifier is causing this message to be displayed. Why is this happening?

Here is the code of the view:

import SwiftUI

struct ArtistRegisterBio: View {
    @ObservedObject var viewModel: ArtistRegisterBioViewModel
    @FocusState var focused
    
    var body: some View {
        Screen {
            VStack {
                ScrollView {
                    VStack {
                        heading
                            .padding(.bottom)
                        bioField
                        Spacer()
                    }
                }
                .padding(.all)
                .safeAreaInset(edge: .bottom) {
                    continueButton
                }
            }
        }
        .onAppear {
            focused.toggle() // causing the message to appear
        }
    }
    
    @ViewBuilder var heading: some View {
        Text("Tell your story")
            .font(.title2)
            .fontWeight(.heavy)
    }
    
    @ViewBuilder var bioField: some View {
        TextField("Bio", text: $viewModel.bio, axis: .vertical)
            .lineLimit(12, reservesSpace: true)
            .textFieldBackground()
            .focused($focused)
    }
    
    @ViewBuilder var continueButton: some View {
        Button {
            viewModel.continueClicked?(viewModel.repository)
        } label: {
            Text("Continue")
                .frame(maxWidth: .infinity)
                .fontWeight(.heavy)
                .gradientBorder(valid: viewModel.valid)
        }
        .disabled(!viewModel.valid)
        .padding([.horizontal, .bottom])
        .padding(.top)
    }
}
pineapple
  • 1
  • 1
  • 2

0 Answers0