Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f9affd7

Browse files
committed
Show loading... when the data is being fetched
1 parent b200b7c commit f9affd7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/pages/index.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export type HomePageFeedUpdateType = {
3131
}
3232

3333
export default function Home() {
34-
const [session] = useSession()
34+
const [session, loading] = useSession()
3535

3636
const { isLoading, isError, data } = useQuery<{
3737
updates: HomePageFeedUpdateType[]
@@ -57,6 +57,10 @@ export default function Home() {
5757
})
5858
})
5959

60+
if (isGoalLoading || loading || isLoading) {
61+
return <p>loading...</p>
62+
}
63+
6064
if (isError || isGoalError) {
6165
return <p>Something went wrong!!!</p>
6266
}
@@ -66,9 +70,7 @@ export default function Home() {
6670
<Title suffix="Learn. Code. Collaborate.">Coderplex Community</Title>
6771
<HomePageFeed
6872
updates={data?.updates ?? []}
69-
showGoal={Boolean(
70-
!isGoalLoading && !isGoalError && session && goalData?.goal
71-
)}
73+
showGoal={Boolean(session && goalData?.goal)}
7274
goal={goalData?.goal}
7375
/>
7476
</>

0 commit comments

Comments
 (0)