title: React Navigation RangeError: Maximum call stack size exceeded (native stack depth)
body: <p>So I have a screen where I want the user to stay. If he want's to leave I want him to go to a specific screen. If I do it like this:</p>
  <pre class="lang-js prettyprint-override"><code>  useEffect(() =&gt; {
      navigation.addListener(&quot;beforeRemove&quot;, (e) =&gt; {
        e.preventDefault()
        navigation.popToTop()
      })
    }, [navigation])
  </code></pre>
  <p>I get this error: <code>RangeError: Maximum call stack size exceeded (native stack depth)</code></p>
  <p>Even if I change <code>navigation.popToTop()</code> to something else (e.g. <code>navigation.navigate(&quot;Account&quot;)</code>) I'll get the same error :/</p>