JSX (JavaScript XML) is the syntax extension that makes React components feel natural to write. It lets you describe your UI using HTML-like tags directly inside JavaScript, while still giving you full access to JavaScript expressions, variables, and logic. Under the hood, Vite (and the React transform) compiles every JSX element intoDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Byrontosh/FundamentosReact/llms.txt
Use this file to discover all available pages before exploring further.
React.createElement calls, so the browser never sees a single angle bracket from your source. The Primero component below demonstrates five foundational concepts you will use in virtually every component you write.
Key concepts
Variable — A regular JavaScript variable (or object) declared inside a component function holds data that can be rendered inside JSX using curly-brace interpolation{value}. Variables are re-evaluated on every render, making them the simplest way to derive display values from your component’s state or props.
Fragment — React requires that every component returns a single root element. Rather than wrapping siblings in a redundant <div>, a Fragment (<React.Fragment> or the shorthand <>...</>) groups multiple elements without adding any extra node to the real DOM. This keeps your markup clean and avoids unintended styling side-effects.
JSX — JSX is the syntax that lets you write <h1>Hello</h1> inside a .jsx file. Curly braces {} act as an escape hatch back into JavaScript, allowing you to embed variables, call functions, or evaluate expressions inline. JSX is not HTML — attributes use camelCase (className instead of class, onClick instead of onclick), and every tag must be explicitly closed.
Conditional — React does not have a special directive for conditional rendering. Instead you use plain JavaScript inside JSX: the ternary operator condition ? a : b is the most common pattern for inline conditionals, while && is handy for rendering something only when a condition is truthy. In Primero.jsx the user’s rol is compared against "Admin" to decide whether to display "Administrador" or "Invitado".
Eventos — Event handlers in React are props whose names match the DOM event name in camelCase (e.g. onClick, onChange, onSubmit). You pass a function reference or an inline arrow function as the value. When the event fires, React calls your handler and you can update state, navigate, or trigger any other side effect. In Primero.jsx, an inline arrow function on the onClick prop of the button calls alert("cierre de sesion").
Example component
The following is the complete source ofPrimero.jsx as it appears in the project. It combines all five concepts in a single, focused component.
Concepts at a glance
| Concept | What it does | Example |
|---|---|---|
| Variable | Stores data that can be interpolated inside JSX | const user = { name: "Byron", rol: "Admin" } → {user.name} |
| Fragment | Groups multiple sibling elements with no extra DOM node | <>...</> wraps the entire component return |
| JSX | Blends HTML structure with JavaScript expressions via {} | <h2>Bienvenido(a) - {user.name}</h2> |
| Conditional | Renders different content based on a runtime value | {user.rol === "Admin" ? "Administrador" : "Invitado"} |
| Eventos | Attaches a handler function to a native browser event | onClick={() => { alert("cierre de sesion") }} |
