Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!