title: Timer crashing screens in SwiftUI
body: <p>I have an app that is using a timer to scroll programmatically between views on the onboarding screen. From the onboarding screen, I can go to login then signup screen (or profile then my account screen). In both ways, when opening the login screen and clicking on signup, the signup screen appears but then disappears and takes me back to login (The same happens when I try to enter My Account screen from the profile screen). Check please the gif attached.</p>
  <p>I've searched all around the web without finding any similar issue.</p>
  <p><strong>Note: I am using NavigationLink to navigate between screens, and I tried also to use both Timer, and Timer.TimerPublisher leading me to the same result, the screens will crash once the timer fires.</strong></p>
  <p><strong>Note: When removing the timer (or the code inside onReceive) everything works fine. I also suspect that the issue could be related to <code>menuIndex</code></strong></p>
  <pre><code>struct OnboardingView: View {
  
  //MARK: - PROPERTIES
  
  @State var menuIndex = 0
  @State var openLogin = false
  let timer = Timer.publish(every: 4, on: .main, in: .common).autoconnect()
  
  //MARK: - BODY
  
  var body: some View {
      
      NavigationLink(destination: LoginView(), isActive: $openLogin) {}
      
      VStack (spacing: 22) {
          
          ProfileButton(openProfile: $openLogin)
              .frame(maxWidth: .infinity, alignment: .trailing)
              .padding(.horizontal, 22)
              
              OnboardingMenuItem(text: onboardingMenu[menuIndex].title, image: onboardingMenu[menuIndex].image)
                  .frame(height: 80)
                  .animation(.easeInOut, value: menuIndex)
                  .onReceive(onboardingVM.timer) { input in
                      if menuIndex &lt; onboardingMenu.count - 1 {
                          menuIndex = menuIndex + 1
                      } else {
                          menuIndex = 0
                      }
                  }
              ...
          }
      }
  }
  </code></pre>
  <img src="https://imgur.com/VlhxVHM.gif">