Skip to content

Commit af0a57f

Browse files
committed
Refactor: make loading component customizable with message prop
1 parent b4d21e6 commit af0a57f

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

app/loading.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
import Image from "next/image";
22

3-
export default function Loading() {
3+
interface LoadingProps {
4+
message?: string;
5+
}
6+
7+
export default function Loading({ message }: LoadingProps = {}) {
8+
const displayMessage = message ?? "Loading...";
9+
410
return (
511
<div className="min-h-screen bg-gradient-to-br from-green-50 via-yellow-50 to-[#FFC517]/10 flex items-center justify-center">
612
<div className="text-center">
713
<Image
814
src="/logo-animated.gif"
9-
alt="Loading..."
15+
alt={displayMessage}
1016
width={80}
1117
height={80}
1218
unoptimized
1319
className="w-20 h-20 mx-auto mb-4"
1420
/>
15-
<p className="text-gray-600">Loading articles...</p>
21+
<p className="text-gray-600">{displayMessage}</p>
1622
</div>
1723
</div>
18-
)
19-
}
24+
);
25+
}

app/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export default function HomePage() {
7575
)
7676

7777
if (loading) {
78-
return <Loading />
78+
return <Loading message="Loading articles..." />
7979
}
8080

8181
if (!paginatedData) {

0 commit comments

Comments
 (0)