Concept
A component is a function that takes props and returns JSX. React calls it whenever the props or its state change, so the function must describe the UI from its inputs and nothing else.
The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.
A few lines that show Function components doing its job.
function Price({ cents, currency = "USD" }: { cents: number; currency?: string }) {
const amount = (cents / 100).toLocaleString("en-US", {
style: "currency",
currency,
});
return <span className="price">{amount}</span>;
}
<Price cents={1999} />Defining a component inside another component's body. It is a new function on every render, so React unmounts and remounts it each time, losing its state and focus.
Your roadmap puts these before Function components, unless you already know them.
Once a session shows you understand Function components, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.
Topics that build on Function components.