Capítulo 1 de 116
This single page covers ~80% of the React concepts used daily: components, JSX, styling via className, displaying data with {}, conditional rendering, list rendering with key, event handlers, and state via useState — everything else in the docs is depth on these fundamentals.
<MyButton />) from a native HTML tag (<button>).<br />), and a component can only return one root element (wrap siblings in <div> or a fragment <>...</>).className is React's class — CSS still lives in a separate .css file; React itself doesn't prescribe how you load it.{} in JSX escapes back into JavaScript — for text content ({user.name}) or, without quotes, for attribute values (src={user.imageUrl}). style={{...}} is just a plain JS object passed through that same escape hatch, not special syntax.if/else, the ternary ? : (works inline in JSX, unlike if), or && for an "only render when true" shortcut.array.map(), and every resulting element needs a stable key (usually a data ID) so React can track inserts/removes/reorders correctly.onClick={handleClick}), never call it (onClick={handleClick()} fires immediately at render time instead of on click).useState: const [count, setCount] = useState(0) — gives a state variable and its setter; calling the setter re-renders the component with the new value. Each rendered instance of a component owns its own independent state.use; they may only be called at the top level of a component (or another Hook) — never inside conditions, loops, or nested functions.useState call to their closest common parent and pass the value + updater down as props — this is how independent per-button counters become one shared counter.function MyButton({ count, onClick }) {
return <button onClick={onClick}>Clicked {count} times</button>;
}
export default function MyApp() {
const [count, setCount] = useState(0);
function handleClick() { setCount(count + 1); }
return (
<div>
<MyButton count={count} onClick={handleClick} />
<MyButton count={count} onClick={handleClick} />
</div>
);
}
MyButton into the shared parent MyApp, then passed back down as props (count, onClick) so both buttons stay in sync — the canonical "lifting state up" pattern.onClick={fn()}); pass the reference (onClick={fn}).key, ideally a stable ID from your data — not the array index, which breaks on reorder/insert/delete.useState calls.eslint-plugin-react-hooks lint rules (Ch 46-47).useState only introduced here.