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

135
Vistas
Struggling to debug invalid hook call on Expo with useEffect

When selecting an address from Places Autocomplete (ie onPress), I am calling a function to try and return the value of geocodeAsync from Expo location. I am however getting an invalid hook call when this function is being called, any advice would be lovely.

function getArray(data) {
    React.useEffect(() => {
        async function getPromise() {
            const res = await geocodeAsync(data); // type: Promise<Interface>
            setCoordinates(res);
        }
        void getPromise();
    }, [])
    const [coordinates2, setCoordinates] = React.useState<LocationGeocodedLocation[]>()
    return coordinates2

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

0

Your outer function needs to have the prefix use so it can be parsed as a hook by React (i.e. useGetArray). You should also define your state before your useEffect so there's no risk of your set function being called before it's defined. See https://reactjs.org/docs/hooks-custom.html.

Also, consider turning on the React lint rules so you aren't missing dependencies in your useEffect.

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