Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

134
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda