Skip to content

Commit

Permalink
Page spinner to tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanjamesdev committed Jun 12, 2022
1 parent ef31893 commit 7988a2d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
26 changes: 17 additions & 9 deletions pages/feed/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import { useRouter } from 'next/router';
import { useEffect, useState } from 'react';
import Navbar from '../../components/Nav/Navbar';
import Post from '../../components/Feed/Post';
import Post from '../../components/Feed/SinglePost';
import Error from '../../components/Hero/Error';
import Spinner from '../../components/Feed/Spinner';

export default function viewPost() {
// Use the router to grab req.query
Expand Down Expand Up @@ -45,14 +46,21 @@ export default function viewPost() {

// Return nav bar if loading
if (isLoading) {
return <Navbar />;
return (
<>
<Navbar />
<Spinner />
</>
);
}

// Return UI, passing data to Post component
return (
<>
<Navbar />
<Post post={postData} />
</>
);
if (!isLoading) {
// Return UI, passing data to Post component
return (
<>
<Navbar />
<Post post={postData} />
</>
);
}
}
8 changes: 7 additions & 1 deletion pages/feed/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { useEffect, useState } from 'react';
import Navbar from '../../components/Nav/Navbar';
import Feed from '../../components/Feed/Feed';
import Spinner from '../../components/Feed/Spinner';

export default function viewFeed() {
// useState to manage data fetching with useEffect
Expand All @@ -24,7 +25,12 @@ export default function viewFeed() {

// Return nav bar if loading
if (isLoading) {
return <Navbar />;
return (
<>
<Navbar />
<Spinner />
</>
);
}

// Return UI, passing data to Feed component
Expand Down

0 comments on commit 7988a2d

Please sign in to comment.