Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

216
Vistas
React Navigation RangeError: Maximum call stack size exceeded (native stack depth)

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:

  useEffect(() => {
    navigation.addListener("beforeRemove", (e) => {
      e.preventDefault()
      navigation.popToTop()
    })
  }, [navigation])

I get this error: RangeError: Maximum call stack size exceeded (native stack depth)

Even if I change navigation.popToTop() to something else (e.g. navigation.navigate("Account")) I'll get the same error :/

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The final array in your code is the useEffect "dependencies array", meaning the useEffect will run whenever anything in that array changes. Adding the listener to the navigation object changes the object, so you're either adding an infinite number of listeners, or replacing the existing one in a loop (I'm not sure how navigation.addListener is implemented).

You need to do one of the following:

  • check that the listener exists in this code block and only add if it doesn't
  • make sure this adding code only executes once
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda