Skip to content

Commit

Permalink
Simplify example
Browse files Browse the repository at this point in the history
  • Loading branch information
MattCCC committed Jul 2, 2023
1 parent e9cef24 commit 183a6da
Showing 1 changed file with 1 addition and 27 deletions.
28 changes: 1 addition & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,38 +140,12 @@ export default api;
import api from '../api/index';

export const useProfile = ({ id }) => {
const {
isLoading,
data,
error,
isFetching,
} = useQuery(['profile', id], () => api.getProfile({ id }), {
return useQuery(['profile', id], () => api.getProfile({ id }), {
initialData: [],
initialDataUpdatedAt: Date.now(),
enabled: id > 0,
refetchOnReconnect: true,
})

if (isLoading || isFetching) {
return {
isLoading,
data: [],
}
}

if (!data) {
return {
isError: true,
error,
data: [],
}
}

return {
isLoading: false,
data,
remove,
}
}

```
Expand Down

0 comments on commit 183a6da

Please sign in to comment.