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: Prevent the loader from rendering more than once on page load #3671

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rumzledz
Copy link
Contributor

@rumzledz rumzledz commented Nov 7, 2024

Description

Note

I appreciate that this may be more of a band-aid solution 🩹

Justification is that, this hook sits on a top-level component and it only ever makes a network request again when the colonyName changes i.e. when you switch Colonies.

colonyName is plucked directly from the URL via useParams() so it should remain constant whilst you're browsing the same Colony.

The issue is that nextFetchPolicy is causing the useGetFullColonyByNameQuery() hook to make the request twice as soon at it gets invoked:

} = useGetFullColonyByNameQuery({
  variables: {
    name: colonyName,
  },
  fetchPolicy: 'network-only',
  nextFetchPolicy: 'cache-only' // <<-- This one
});

Which then causes this component to render twice:

if (
  walletConnecting ||
  isColonyLoading ||
  userLoading ||
  isContributorLoading
) {
  return <LoadingTemplate loadingText={MSG.loadingText} />;
}

Testing

  1. Directly visit a colony: http://localhost:9091/planex/
  2. Verify that the following loader only shows up once:
image

Resolves #3662

@rumzledz rumzledz self-assigned this Nov 7, 2024
@rumzledz rumzledz marked this pull request as ready for review November 7, 2024 13:26
@rumzledz rumzledz requested review from a team as code owners November 7, 2024 13:26
@rumzledz rumzledz changed the title Fix: Prevent the loading view to render more than once on page load Fix: Prevent the loader to render more than once on page load Nov 7, 2024
Copy link
Contributor

@bassgeta bassgeta left a comment

Choose a reason for hiding this comment

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

Legit solution, and I agree with your reasoning 👍

loader-fix-2024-11-07_14.29.26.mp4

@rumzledz rumzledz changed the title Fix: Prevent the loader to render more than once on page load Fix: Prevent the loader from rendering more than once on page load Nov 7, 2024
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.

[QA] App content flashes before showing the loader again
2 participants