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

refactor: use react-query for EditNavBar #358

Merged
merged 7 commits into from
Mar 2, 2021

Conversation

kwajiehao
Copy link
Contributor

Overview

This PR refactors the EditNavBar layout to use react-query, in line with our recent PRs (#350, #357). The GET and POST API calls are now defined as functions within the api.js file, and we replace them with useQuery and useMutation in the EditNavBar code.

This PR also creates a new, simplified LoadingButton component that is compatible with react-query. react-query provides us with the loading state of our api call - this means we don't need to handle it ourselves within our LoadingButton component. The new button component simply receives an isLoading prop and renders a loading spinner and loading styles when isLoading is true.

@kwajiehao kwajiehao marked this pull request as draft February 25, 2021 17:09
@kwajiehao kwajiehao marked this pull request as ready for review March 1, 2021 08:18
Copy link
Contributor

@alexanderleegs alexanderleegs left a comment

Choose a reason for hiding this comment

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

lgtm

This commit refactors the `EditNavBar` component to use react-query
to retrieve nav bar data from the backend. This includes moving the
API call into a callback function defined in the api.js file.
By using react-query, we are also provided with the loading state
of our api call - this means we don't need to handle it ourselves
within our LoadingButton component. This commit introduces a simplified
loading button which simply receives `isLoading` as a prop and renders
a loading spinner and loading styles when `isLoading` is true.
@kwajiehao kwajiehao force-pushed the feat/display-collections-nav-bar branch from b861d0a to 8672b5c Compare March 2, 2021 06:28
@kwajiehao kwajiehao merged commit 9f8b056 into staging Mar 2, 2021
@kwajiehao kwajiehao deleted the feat/display-collections-nav-bar branch March 2, 2021 06:29
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.

3 participants