Page not found.
} else {
- return Loading page...
+ return Loading Page...
}
}
diff --git a/jscript/react/sample-blog/src/components/PostSite.js b/jscript/react/sample-blog/src/components/PostSite.js
index 9969a264..729bbbc2 100644
--- a/jscript/react/sample-blog/src/components/PostSite.js
+++ b/jscript/react/sample-blog/src/components/PostSite.js
@@ -1,6 +1,5 @@
import React from 'react';
import { useParams } from 'react-router-dom';
-
import { Post } from './Post.js';
import { getPost } from './../service';
@@ -13,7 +12,7 @@ export const PostSite = () => {
async function fetchData() {
try {
const result = await getPost(id);
-
+
setPost(result);
} catch (ex) {
setPost(null);
@@ -28,6 +27,6 @@ export const PostSite = () => {
} else if (post === null) {
return Post not found.
} else {
- return Loading post...
+ return Loading Post...
}
}
diff --git a/jscript/react/sample-blog/src/components/PostsSite.js b/jscript/react/sample-blog/src/components/PostsSite.js
index 531b9bf0..3502620d 100644
--- a/jscript/react/sample-blog/src/components/PostsSite.js
+++ b/jscript/react/sample-blog/src/components/PostsSite.js
@@ -1,5 +1,4 @@
import React from 'react';
-
import { Post } from './Post.js';
import { getPosts } from './../service';
@@ -9,7 +8,7 @@ export const PostsSite = () => {
React.useEffect(() => {
async function fetchData() {
const results = await getPosts();
-
+
setPosts(results.posts);
}
@@ -17,14 +16,24 @@ export const PostsSite = () => {
}, []);
if (!posts) {
- return Loading posts...
+ return Loading Posts...
}
- return posts.map(post => (
-
-
+ return (
+ <>
+ {posts.length === 0 ? (
+ <>No Post found>
+ ) : (
+
+ {posts.map(post => (
+
- ));
+
+
+ ))}
+
+ )}
+ >
+ );
}
diff --git a/jscript/react/sample-blog/src/components/TopNav.js b/jscript/react/sample-blog/src/components/TopNav.js
index afc69f19..4ce04132 100644
--- a/jscript/react/sample-blog/src/components/TopNav.js
+++ b/jscript/react/sample-blog/src/components/TopNav.js
@@ -1,6 +1,5 @@
import React from 'react';
import { NavLink } from 'react-router-dom';
-
import { getPages } from './../service';
export const TopNav = () => {