title: How to navigate to another stack's screen while using deep linking in react-navigation v5?
body: <p>In this case, a screen may be opened through deep linking. There's a <code>&lt;BackButton /&gt;</code> component and I wish the button's behavior like this:</p>
  
  <ul>
  <li>if this screen was opened by <code>navigator.navigate</code>, then go back.</li>
  <li>if this screen was opened by deep-linking, then go to the Home screen.</li>
  </ul>
  
  <p>The navigator struct like this</p>
  
  <ul>
  <li>Root (stack navigator)
  
  <ul>
  <li>Tab (bottom tab navigator)
  
  <ul>
  <li>Home</li>
  <li>Personal</li>
  </ul></li>
  <li>Main (stack navigator)
  
  <ul>
  <li>Store</li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p>In the begining, I wrote code like this:</p>
  
  <pre class="lang-js prettyprint-override"><code>const onBackButtonPress = useCallback(() =&gt; {
    if (navigation.canGoBack()) {
      navigation.goBack()
    } else {
      navigation.navigate('Tab', { screen: 'Home' })
    }
  ), [navigation])
  </code></pre>
  
  <p>This code works, however using <code>navigation.navigate()</code> function cause a push effect (new screen comes from the right edge), not go back (new screen comes from the left edge).</p>
  
  <p>Then I tried to use <code>navigation.replace()</code> and <code>navigation.reset()</code></p>
  
  <pre class="lang-js prettyprint-override"><code>navigation.reset({
    index: 0,
    routes: [{ name: 'Tab', state: { routes: [{ name: 'Home' }, { name: 'Personal' }] } }],
  })
  </code></pre>
  
  <p>And the navigator seems couldn't handle this route (I think this is because we're in the <code>Main</code> stack now, and it couldn't handle the params).</p>
  
  <p>What can I do to correct the behavior of navigation?</p>