Skip to content

Commit 546284a

Browse files
authored
fix setloading recursive rendering issue (#106)
1 parent c3d457f commit 546284a

File tree

1 file changed

+4
-26
lines changed

1 file changed

+4
-26
lines changed

ui/src/pages/repos/index.tsx

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -188,17 +188,10 @@ function RepoLine({ repo, deletable, sharable }) {
188188
);
189189
}
190190

191-
function Repos({
192-
url = FETCH_REPOS,
193-
type = RepoTypes.repo,
194-
onLoading = (load) => {},
195-
}) {
191+
function Repos({ url = FETCH_REPOS, type = RepoTypes.repo }) {
196192
const { loading, error, data } = useQuery(url);
197193
if (loading) {
198-
onLoading(loading);
199-
return null;
200-
} else {
201-
onLoading(loading);
194+
return <CircularProgress />;
202195
}
203196
if (error) {
204197
return null;
@@ -299,8 +292,7 @@ function NoLogginErrorAlert() {
299292
}
300293
export default function Page() {
301294
const { me } = useMe();
302-
const [loading, setLoading] = useState(true);
303-
if (!me && !loading) {
295+
if (!me) {
304296
return <NoLogginErrorAlert />;
305297
}
306298
return (
@@ -319,21 +311,7 @@ export default function Page() {
319311
👋 Welcome, {me?.firstname}! Please open or create a repository to get
320312
started.
321313
</Box>
322-
{loading && (
323-
<Box
324-
sx={{
325-
display: "flex",
326-
justifyContent: "center",
327-
}}
328-
>
329-
<CircularProgress />
330-
</Box>
331-
)}
332-
<Repos
333-
onLoading={(value) => {
334-
setLoading(value);
335-
}}
336-
/>
314+
<Repos />
337315
<Repos url={FETCH_COLLAB_REPOS} type={RepoTypes.collab} />
338316
</Box>
339317
);

0 commit comments

Comments
 (0)