Skip to content

fix: fix flashing error dialog in the create workspace page #18180

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

Merged
merged 2 commits into from
Jun 2, 2025

Conversation

jaaydenh
Copy link
Contributor

@jaaydenh jaaydenh commented Jun 2, 2025

This PR which updated react-query to 5.77.0 introduced an issue on the create workspace page where the error dialog would be briefly displayed while the page is loading. #18039

The issue is that there is a moment when optOutQuery.isLoading is false and optOutQuery.data is undefined causing the ErrorAlert to display.

@jaaydenh jaaydenh self-assigned this Jun 2, 2025
@jaaydenh jaaydenh requested review from aslilac and BrunoQuaresma June 2, 2025 14:18
@jaaydenh jaaydenh changed the title fix: flashing error dialog in create workspace page fix: fix flashing error dialog in the create workspace page Jun 2, 2025
@BrunoQuaresma
Copy link
Collaborator

Thanks for fixing it 🙏

@aslilac
Copy link
Member

aslilac commented Jun 2, 2025

what if we did something like

	if (query.isError) {
		return <ErrorAlert error={query.error} />;
	}

	if (!query.data) {
		return <Loader />;
	}

so that we don't need to use the ? operator to read from data after the check?

@jaaydenh
Copy link
Contributor Author

jaaydenh commented Jun 2, 2025

what if we did something like

	if (query.isError) {
		return <ErrorAlert error={query.error} />;
	}

	if (!query.data) {
		return <Loader />;
	}

so that we don't need to use the ? operator to read from data after the check?

I suppose that works but looking at the react query docs, it feels like using isLoading/isPending is the straight-forward clearest way to do things, https://tanstack.com/query/latest/docs/framework/react/guides/queries

@aslilac
Copy link
Member

aslilac commented Jun 2, 2025

but they don't give us the type safety that checking data directly does. I really prefer narrowing the type rather than using ?. everywhere and assuming it'll be fine.

@jaaydenh jaaydenh merged commit fd6981e into main Jun 2, 2025
33 checks passed
@jaaydenh jaaydenh deleted the jaaydenh/react-query-fix branch June 2, 2025 20:55
@github-actions github-actions bot locked and limited conversation to collaborators Jun 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants