#100DAYSOFCODE Day90

#100DAYSOFCODE Day90

Improve Yulp

Change using React Query to manage the fetching data function.

Normally(Example), it uses the first prams to pass data as Array. You can pass prams like geolocation to fetch function.

const { data, status, isLoading } = useQuery(["fetchByLocation", geolocation], getYelpData)

In fetch function, it would be an object called queryKey. The first one is 'fetchByLocation, so the second one is geolocation.

export const getYelpData = ({ queryKey }) => {

  const location = queryKey[1]
  ...

React Query helps easy to manage status and loading. Also, it has some cool functions I didn't use.