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

fix: fix loading of records in explorer view #286

Merged
merged 1 commit into from
May 24, 2024

Conversation

Odonno
Copy link
Contributor

@Odonno Odonno commented May 19, 2024

Fix loading of records, especially when switching tables that takes some time to load.

  • Add @tanstack/react-query and @tanstack/eslint-plugin-query packages
  • useQuery to simplify the loading logic of records (having isLoading, data and refresh properties already available)
  • use LoadingOverlay from mantime when records are loading

Example:

image

@Odonno Odonno requested a review from macjuul as a code owner May 19, 2024 21:45
@Odonno Odonno force-pushed the fix/explorer-loading-records branch from 8ff16b1 to c465e92 Compare May 22, 2024 15:39
@macjuul
Copy link
Contributor

macjuul commented May 22, 2024

I'm uncertain whether adding the complexity and additional bundle size of @tanstack/react-query warrants replacing the currently implementation. Would it provide any further benefits besides being more standardized?

Adding in a loading indicator however is a great change!

@Odonno
Copy link
Contributor Author

Odonno commented May 22, 2024

Good question.

I started to use it once I saw the complexity of the Explorer component. I suppose this is the most complex component compared to the other but I may be wrong. If we are using @tanstack/react-query only once, it is indeed overkill. But I can see its usage in the different part of the app:

  • for any fetch call (query page, explorer page, functions page, etc...)
  • for other type of async task (like import/export, etc...)

I can see many benefits of using this library, both short-term and long-term:

  • having the isLoading and error properties by design, and improving the UI accordingly
  • having built-in caching mechanism
  • support of cancellation request, when we will be able to cancel db queries in the future
  • could also work for sync state, possible removing the need for zustand if we want to reduce bundle size on this matter

@macjuul macjuul merged commit 3087ee6 into surrealdb:main May 24, 2024
1 check passed
@Odonno Odonno deleted the fix/explorer-loading-records branch May 24, 2024 13:36
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.

None yet

2 participants