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

useLoadedData may return stale data #10594

Open
kr-matthews opened this issue Jan 10, 2025 · 1 comment
Open

useLoadedData may return stale data #10594

kr-matthews opened this issue Jan 10, 2025 · 1 comment

Comments

@kr-matthews
Copy link
Contributor

Describe the bug

If the url changes in useLoadedData, then sync is called again, triggering another fetch. If another fetch was already in progress, and finishes after this new fetch, then it will overwrite the new (expected) result.

This hook is used a lot. Replacing uses with @tanstack/react-query's useQuery should resolve the issue, as well as bring multiple advantages, such as automatic data caching.

Probably the cause of #8760 too.

To Reproduce

For a concrete example, see https://www.worldcubeassociation.org/teams-committees-councils. If you click on several different teams in quick succession, multiple fetches will trigger, and whichever happens to finish last will decide what data is shown in the table (title, description, and contact info is fetched separately, and will be correct).

image

@FinnIckler
Copy link
Member

I think we have an issue to replace all usages of useLoadedData. I think the easier solution would be to use it as a wrapper for useQuery and then replace the usages.

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

No branches or pull requests

2 participants