Complete the code to create a layout component that wraps page content.
export default function Layout({ children }) {
return (
<div>[1]>{children}</div>
)
}The layout div should have a className for styling. Here, className="layout" is correct.
Complete the code to import the usePathname hook from Next.js navigation.
import { [1] } from 'next/navigation';
useRouter with usePathname.The usePathname hook is imported from next/navigation to get the current path.
Fix the error in the layout component to correctly use the usePathname hook.
import { usePathname } from 'next/navigation'; export default function Layout({ children }) { const path = [1](); return <div>{children}</div>; }
useRouter instead of usePathname.The hook usePathname must be called as a function to get the current path.
Fill both blanks to conditionally add an active class to a navigation link based on the current path.
const path = usePathname(); return ( <nav> <a href="/about" className={path [1] '/about' ? 'active' : ''}>About</a> <a href="/contact" className={path [2] '/contact' ? 'active' : ''}>Contact</a> </nav> );
== or !=.Use strict equality === to compare the current path with the link href for accurate matching.
Fill all three blanks to create a layout that includes a header, main content, and footer with semantic HTML.
export default function Layout({ children }) {
return (
<[1]>
<h1>Site Title</h1>
</[1]>
<[2]>
{children}
</[2]>
<[3]>
<p>Ā© 2024 My Site</p>
</[3]>
);
}div instead of semantic tags.Use semantic HTML tags: header for the top, main for main content, and footer for the bottom.