Trail shoes
$ 129.00
In stockThis is part 1 of the Modern React development series.
React starts with a small promise: describe the user interface as components, then let React keep the browser output in sync with that description. JSX is the notation most React projects use for that description, so the markup, data reads, and component calls live in one JavaScript expression.
A React component is a JavaScript function that returns a React node, usually written with JSX. JSX looks like HTML, but it is JavaScript syntax that can call components, pass props, read variables in curly braces, and produce a tree of elements for React to render.
<>...</> when a component needs to return adjacent nodes without adding a DOM element.Treat a component like a pure recipe card. Given the same props, it writes the same UI recipe. React reads that recipe, compares it with the previous one, and updates the page where the recipe changed.
Components are used for everything from a single button to a whole route. JSX lets a component keep the visible structure next to the JavaScript values that fill it in, such as a product name, an image URL, or a conditional badge.
import type { ReactElement } from "react";
type ProductCardProps = { name: string; priceCents: number; inStock: boolean;};
export function ProductCard({ name, priceCents, inStock,}: ProductCardProps): ReactElement { const price = (priceCents / 100).toFixed(2);
return ( <article className="product-card"> <h2>{name}</h2> <p>$ {price}</p> {inStock ? <span>In stock</span> : <span>Back soon</span>} </article> );}$ 129.00
In stockThe component reads plain values, calculates display text, and returns JSX. The conditional badge is still normal JavaScript expressed inside the returned tree.
import { ProductCard } from "./ProductCard";
type Product = { id: string; name: string; priceCents: number; inStock: boolean;};
export function ProductGrid({ products }: { products: Product[] }) { return ( <section aria-labelledby="featured-products"> <h2 id="featured-products">Featured products</h2> <div className="grid"> {products.map((product) => ( <ProductCard key={product.id} {...product} /> ))} </div> </section> );}$ 129.00
In stock$ 99.00
Back soonThe parent owns the list shape and calls ProductCard for each item. Composition keeps the card focused on one product and the grid focused on layout.
div and button. Capitalized names are treated as React components.return.