Document metadata
The browser tab shows a title, and search engines read a description. That
information lives in the document's <head>, far from the component that knows
what the page is about. Keeping the two in sync by hand is easy to forget.
Components can render document metadata — the <title> and <meta> tags that
belong in a document's <head> — right where the data lives:
function LessonPage() {
return (
<article>
<title>Reading: Props</title>
<meta name="description" content="How props flow through a tree" />
<h1>Reading: Props</h1>
</article>
);
}
You do not have to reach into document.head yourself. React recognises
<title> and <meta> anywhere in the tree and hoists them into the
document <head> when the component commits. A hoisted <title> becomes the
document's title; hoisted <meta> tags land in the head with the rest of the
page's metadata.
Keeping metadata next to the component that owns it means you never scatter
head tags across a template. If two components render the same
<meta name="description">, React deduplicates them and the last one rendered
wins. When the metadata changes on a re-render, React updates the head to match,
so a title driven by props stays in sync.
Your job is to render the page's title and description from inside the component.
Challenge
The browser tab has no title of its own yet — the page renders a heading and
nothing else. Export an App component from App.jsx that renders a
<title> and a <meta name="description"> alongside its heading.
The Test renders <App /> and checks that document.title becomes the title
your component rendered — proof that React hoisted the <title> into the
document head. The starter renders only a heading, so the Test fails.