Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use React Query #19

Merged
merged 3 commits into from
May 10, 2024
Merged

Use React Query #19

merged 3 commits into from
May 10, 2024

Conversation

LamboCreeper
Copy link
Member

Since we will be doing a lot of API calls to GitHub and Firestore in this project, I believe it is beneficial to use a caching system. I have gone for React Query as it seems like it should do everything we need and more.

I've set it up and replaced all instances of useGitHub() with a React Query implementation. This is my first time using this library, so hopefully we're doing it right!

}, [user, request]);
const { data: gitRepositories } = useQuery({
queryKey: ["github", "repositories", gitUser?.login.toLowerCase()],
queryFn: async () => githubService.getUsersRepositories(gitUser!.login),
Copy link
Collaborator

@Jason2605 Jason2605 May 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to await here?
Or not mark it as async and just return the call to getUserRepository

Copy link
Member Author

@LamboCreeper LamboCreeper May 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need since the Promise is being directly returned. I don't think there is any advantage to having the Promise resolved within the scope of queryFn.

Discussed on Discord - will change.

@LamboCreeper LamboCreeper merged commit dd3ffa1 into master May 10, 2024
2 checks passed
@LamboCreeper LamboCreeper deleted the react-query branch May 10, 2024 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants