Complete the code to create a layout component that wraps page content.
export default function Layout({ children }) {
return <[1]>{children}</[1]>;
}The
Complete the code to define a Next.js template that renders a page with a title.
export default function Template() {
return <div><h1>[1]</h1></div>;
}In JSX, static text placed directly between opening and closing tags renders as content without quotes.
Fix the error in the layout component to correctly include the header and children.
export default function Layout({ children }) {
return (
<div>
[1]
{children}
</div>
);
}
function Header() {
return <header>Site Header</header>;
}In React/Next.js, components must be used as JSX tags with capitalized names and self-closing or with children.
Fill both blanks to create a template that uses a layout and renders page content.
import Layout from './Layout'; export default function Template() { return ( <[1]> <p>Hello, world!</p> </[2]> ); }
The template uses the Layout component to wrap its content, so both opening and closing tags must be <Layout> and </Layout>.
Fill all three blanks to create a layout with header, main content, and footer.
export default function Layout({ children }) {
return (
<>
<[1]>Site Header</[2]>
<[3]>{children}</[3]>
<footer>Site Footer</footer>
</>
);
}The header and its closing tag use <header>, and the main content uses <main> tags to wrap children.