Skip to content

Commit

Permalink
loader while loading posts and error formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
VaibhavArora314 committed May 27, 2024
1 parent dbaf6dd commit b3a3265
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/Loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const Loader = () => {
return (
<div
role="status"
className="h-screen w-screen flex items-center justify-center bg-gray-50"
className="h-screen w-screen flex items-center justify-center"
>
<svg
aria-hidden="true"
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/pages/Posts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';
import axios from 'axios';
import { Link } from 'react-router-dom';
import { PostData } from '../types';
import Loader from '../components/Loader';

const Posts = () => {
const [posts, setPosts] = useState<PostData[]>([]);
Expand All @@ -24,11 +25,11 @@ const Posts = () => {
}, []);

if (loading) {
return <div>Loading...</div>;
return <Loader/>;
}

if (error) {
return <div>{error}</div>;
return <div className='text-red-500 font-semibold text-lg text-center'>{error}</div>;
}

return (
Expand Down

0 comments on commit b3a3265

Please sign in to comment.