adrianhajdin/project_react_native_jobs

Data Fetching / useFetch Hook not working as expected

Opened this issue · 15 comments

Issue
Always getting empty response, even on debugging, it shows only one section data(either popular or nearby )

Please help!

For the issue where it sometimes shows popular jobs and sometimes nearby jobs, I made slight changes. I created another hook named "useFetcher" and made a second account on rapid api. The key I recieved from the second account I used it for useFetcher hook. Now I used useFetcher hook for fetching popular jobs and search functionality and useFetch hook for nearbyjobs.

For reference you can refer to my code : https://github.com/Jatan88/JobSpot

Please drop a like if you find it useful.

For the issue where it sometimes shows popular jobs and sometimes nearby jobs, I made slight changes. I created another hook named "useFetcher" and made a second account on rapid api. The key I recieved from the second account I used it for useFetcher hook. Now I used useFetcher hook for fetching popular jobs and search functionality and useFetch hook for nearbyjobs.

For reference you can refer to my code : https://github.com/Jatan88/JobSpot

Please drop a like if you find it useful.

Great way to deal it with brute force!

You are a lifesaver bro

Happy to help!

you can use dummy data while developing the app to reduce API calls
jobData.js.zip

Я вніс невеликі зміни до випуску, де іноді показуються популярні вакансії, а іноді вакансії поблизу. Я створив інший хук під назвою "useFetcher" і створив другий обліковий запис на rapid api. Ключ, який я отримав від другого облікового запису, я використав для використання хука Fetcher. Тепер я використовував хук useFetcher для отримання популярних вакансій і функцій пошуку та використовував хук Fetch для найближчих вакансій.

Для довідки ви можете звернутися до мого коду: https://github.com/Jatan88/JobSpot

Будь ласка, поставте лайк, якщо вважаєте це корисним.

It dosen't work

Make sure you follow the steps correctly.

Created the same hook only under a different account, as you said. And used it for popular works. But it still renders sometimes popular ones and nearby ones

Can you take a screenshot of the hook useFetcher?
Access to your repository is not available

Similarly, everything is the same
But now it work. Thanks

if anybody wants not to create two accounts of Rapid Api and not two hooks for fetching you could apply a little shortcut
add this line {!data && refetch()} after usefetch hook into Both component like popularjob and rearbyjob it will fix issue. get advantage of refetch() function built in that video.
check my github for more infoThanks.

hvkst commented

{!data && refetch()}

I will try that :)

For now I used setTimeout in the useFetchHook:
const useFetch = (endpoint, query, delay) => {...
useEffect(() => { setTimeout(() => fetchData(), delay || 10); }, []);

and then in the components

const { data, isLoading, error } = useFetch( 'search', { query: 'Javascript developer', num_pages: 1, }, 3000 );

Adding timeout works but I don't think so it is the best method. I also tried refetch method in PopularJobs.js. The code I used was

if(error)
{
refetch
}

This didn't work either. Still, I was getting the alert popup.

hello guys, newbie here
hope you are all well.
I am getting the following error,
objects are not valid as a react child(found: object with keys {data, isLoadingm error, refetch}). if you meant to render a collection of children, use an array instead.
help is appreaciated

Hey everyone if you run into an error which doesnt allow the popularjobs to render, due to an error like "SetIsLoading" or "isLoading: is not defined please change that to setLoading and loading respectively and it will solve your issue.

i believe react native got an update which some changes has been made. I hope this helps. Shoot me a message and i can personally look at the code.