Skip to content

Commit afb0a26

Browse files
[dashboard] Avoid re-rendering the whole App on Org load (#16976)
* [dashboard] Avoid re-rendering the whole App on Org load * remove req of curr org to handle personal accounts --------- Co-authored-by: Brad Harris <[email protected]>
1 parent ed32312 commit afb0a26

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

components/dashboard/src/App.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,18 @@ const App: FunctionComponent = () => {
5151
if (!user) {
5252
return <Login />;
5353
}
54-
// TODO(gpl) "isLoading" is "true" even if there are errors in this "useCurrentOrg" call.
55-
// Why don't understand as to why .isLoading is not resolved at some point, though. Maybe we're missing proper error handling for useOrganizations
56-
// if (currentOrgQuery.isLoading) {
57-
// return <AppLoading />;
58-
// }
54+
55+
// At this point we want to make sure that we never render AppRoutes prematurely, e.g. without finishing loading the orgs
56+
// This would cause us to re-render the whole App again soon after, creating havoc with all our "onMount" hooks.
57+
if (currentOrgQuery.isLoading) {
58+
return <AppLoading />;
59+
}
5960

6061
// If we made it here, we have a logged in user w/ their teams. Yay.
6162
return (
6263
<Suspense fallback={<AppLoading />}>
63-
{/* Use org id as key to force re-render on org change */}
64-
<AppRoutes key={currentOrgQuery.data?.id ?? "no-org"} />
64+
{/* Use org id, or user id (for personal account) as key to force re-render on org change */}
65+
<AppRoutes key={currentOrgQuery?.data?.id ?? user.id} />
6566
</Suspense>
6667
);
6768
};

0 commit comments

Comments
 (0)