Menu
Coddy logo textTech

Step 4: Loading State

Part of the Next.js Essentials section of Coddy's React journey — lesson 42 of 47.

challenge icon

Challenge

Easy

Give the dish route a skeleton.

  1. Create app/menu/[slug]/loading.jsx exporting a default component (no props, not async).
  2. Return a <div className="detail"> holding a <div> with id="dish-skeleton" and className="detail-thumb skeleton".
  3. Add a second child with className="empty" and any waiting text, something better than the word Loading.

Try it yourself

import Link from 'next/link';
import './globals.css';

export const metadata = {
    title: {
        default: 'Coddy Eats',
        template: '%s | Coddy Eats',
    },
};

export default function RootLayout({ children }) {
    return (
        <html lang="en">
            <body>
                <nav className="nav">
                    <Link className="brand" href="/">Coddy Eats</Link>
                    <Link id="nav-menu" href="/">Menu</Link>
                    <Link id="nav-desserts" href="/?category=dessert">Desserts</Link>
                </nav>
                <div className="container">
                    {children}
                </div>
            </body>
        </html>
    );
}

All lessons in Next.js Essentials