React Tutorial
Build interactive user interfaces with components, state and hooks.
Getting started6 lessons
- 1React IntroductionReact is a JavaScript library for building user interfaces from small reusable pieces call.
- 2React Get StartedThe quickest way to start is a build tool such as Vite.
- 3JSX SyntaxJSX looks like HTML inside JavaScript.
- 4JSX ExpressionsAny JavaScript expression goes inside curly braces: variables, math, function calls and te.
- 5Fragments and RenderingA component returns one root.
- 6Project StructureA Vite project has index.html, src/main.jsx which mounts the app, src/App.jsx and a compon.
Components8 lessons
- 7Function ComponentsA component is a function that starts with a capital letter and returns JSX.
- 8PropsProps pass data from a parent to a child, like function arguments.
- 9Children and CompositionThe special children prop holds whatever is placed between the tags.
- 10Conditional RenderingRender different UI with ternaries, && or early returns.
- 11Lists and KeysUse map to turn an array into elements.
- 12Styling ComponentsStyle with className and a CSS file, with the style prop taking an object of camelCase pro.
- 13Importing and Exporting ComponentsPut each component in its own file, export it and import it where needed.
- 14Pure ComponentsA pure component returns the same JSX for the same props and state and does not change out.
State and events19 lessons
- 15Handling EventsPass a function to props such as onClick and onChange.
- 16The useState HookuseState gives a component memory.
- 17State Updates and SnapshotsState is a snapshot for each render.
- 18State with Objects and ArraysNever mutate state.
- 19Controlled InputsA controlled input shows a value from state and updates it in onChange.
- 20Lifting State UpWhen two components need the same data, move the state to their closest common parent and .
- 21Forms and SubmitHandle onSubmit on the form, call preventDefault to stop the page reload and read values f.
- 22useStateuseState returns the value and a setter.
- 23Functional UpdatesWhen the next value depends on the previous one, pass a function.
- 24State with ObjectsNever mutate state.
- 25State with ArraysUse map, filter and spread to add, change and remove items.
- 26Handling EventsHandlers are camelCase props that receive a synthetic event.
- 27Passing Arguments to HandlersWrap the call in an arrow function to pass arguments.
- 28Controlled InputsA controlled input gets value from state and updates it on change.
- 29Checkboxes and SelectsUse checked for checkboxes and value for selects.
- 30Forms and SubmitCollect values in state and submit with onSubmit.
- 31Lifting State UpMove shared state to the nearest common parent and pass it down.
- 32Lazy Initial StatePass a function to useState to run expensive setup only once.
- 33Resetting State with keyChanging a key remounts a component and resets its state.
Lists and forms6 lessons
- 34Checkbox, Select and TextareaCheckboxes use checked, selects and textareas use value.
- 35A Todo ListCombine state, a list and events.
- 36Derived ValuesDo not store what you can calculate.
- 37Form ValidationValidate on submit or as the user types.
- 38Keys and Resetting StateA different key makes React treat the element as new, so its state resets.
- 39Sorting and Filtering ListsCopy before sorting because sort mutates.
Effects and refs7 lessons
- 40The useEffect HookuseEffect runs code after render to sync with outside systems such as timers, subscription.
- 41Effect CleanupReturn a function from an effect to clean up timers and listeners.
- 42Fetching DataFetch in an effect, store the result in state and handle loading and error states.
- 43The useRef HookuseRef holds a mutable value that survives renders without causing one.
- 44You Might Not Need an EffectAvoid effects for things you can compute while rendering or handle in an event.
- 45Strict Mode and Development ChecksStrictMode runs components twice in development to reveal impure code and missing cleanups.
- 46Routing with React RouterReact Router maps URLs to components without reloading.
Advanced ReactPremium11 lessons
- 47useReduceruseReducer manages complex state with a reducer function that takes state and an action an.
- 48ContextContext passes data through the tree without prop drilling.
- 49useMemo and useCallbackuseMemo caches a calculated value and useCallback caches a function between renders.
- 50React.memomemo skips re-rendering a component when its props did not change.
- 51Custom HooksA custom hook is a function starting with use that calls other hooks.
- 52Rules of HooksCall hooks only at the top level of components or custom hooks, never inside loops, condit.
- 53Lazy Loading with SuspenseReact.lazy loads a component only when needed and Suspense shows a fallback while it loads.
- 54Error BoundariesAn error boundary catches errors in its children while rendering and shows a fallback inst.
- 55Portals and forwardRefcreatePortal renders children into another DOM node such as document.body, useful for moda.
- 56useId, useTransition and useDeferredValueuseId makes stable ids for labels.
- 57Server Components and FrameworksServer Components render on the server and send HTML and data, so less JavaScript reaches .
React in practicePremium9 lessons
- 58Choosing State ManagementStart with local state, lift it up and use context for rarely changing values.
- 59Testing ComponentsTest what users see and do with React Testing Library and a runner such as Vitest.
- 60Performance TipsMeasure with the React DevTools profiler first.
- 61AccessibilityUse semantic elements, label every input, manage focus after navigation, add alt text and .
- 62React with TypeScriptType props with an interface or type.
- 63Project OrganisationGroup by feature rather than type: each feature folder holds its components, hooks and tes.
- 64Environment, Build and DeployVite exposes variables that start with VITE_.
- 65React Best PracticesKeep components small and pure, lift state only as high as needed, avoid effects for deriv.
- 66Next StepsBuild a small project such as a todo app, a weather app and a shop.
React basics11 lessons
- 67JSX RulesJSX must return one root element, close every tag and use className instead of class.
- 68Expressions in JSXCurly braces embed any JavaScript expression in markup.
- 69FragmentsA fragment groups siblings without adding a DOM node.
- 70Inline StylesThe style prop takes an object with camelCase keys.
- 71Conditional RenderingUse ternaries and && to show content conditionally.
- 72Lists and Keysmap builds lists.
- 73Function ComponentsA component is a function that returns JSX.
- 74PropsProps pass data from parent to child.
- 75The children PropAnything between tags arrives as children.
- 76Spreading PropsThe spread operator forwards an object as props.
- 77Import and ExportSplit components into files with default and named exports.
Hooks in depth13 lessons
- 78useEffectuseEffect runs after render for side effects like fetching or timers.
- 79Effect CleanupReturn a function to clean up timers and listeners.
- 80Fetching in an EffectLoad data in an effect and guard against stale responses.
- 81Dependency RulesList every reactive value the effect uses.
- 82useRefuseRef holds a mutable value that does not trigger renders and can point to a DOM node.
- 83useMemouseMemo caches a calculated value until dependencies change.
- 84useCallbackuseCallback keeps a function identity stable between renders.
- 85useReduceruseReducer manages complex state with a reducer function.
- 86ContextContext passes data deep without prop drilling.
- 87Custom HooksA custom hook is a function starting with use that calls other hooks.
- 88Rules of HooksCall hooks only at the top level of components or custom hooks.
- 89useId and useLayoutEffectuseId makes stable ids.
- 90useTransitionuseTransition marks updates as non urgent so typing stays smooth.
Components and patterns11 lessons
- 91Composition over InheritanceBuild UIs by combining components, not extending them.
- 92Render PropsPass a function as a prop to share rendering logic.
- 93Higher Order ComponentsA HOC wraps a component and returns an enhanced one.
- 94PortalscreatePortal renders children into another DOM node.
- 95Error BoundariesA class with getDerivedStateFromError catches render errors below it.
- 96lazy and Suspenselazy loads a component on demand and Suspense shows a fallback.
- 97React.memomemo skips re-rendering when props are unchanged.
- 98Refs to ChildrenPass a ref to a child so the parent can reach its DOM node.
- 99Typing PropsDocument props with TypeScript or PropTypes.
- 100Container and PresentationalSeparate data logic from display components.
- 101Compound ComponentsRelated components share state through context.
Real world React21 lessons
- 102Conditional ClassesBuild class names from state.
- 103Routing BasicsA router maps URLs to components.
- 104Route ParametersuseParams reads dynamic URL parts.
- 105Loading and Error StatesTrack status so the UI always shows something.
- 106Debouncing InputWait for the user to pause before running a costly action.
- 107Persisting StateSync state to localStorage with an effect.
- 108Theme SwitcherCombine context and state for a theme toggle.
- 109Project: Todo AppCombine state, lists and forms into a small app.
- 110Project: StopwatchUse state, effect and cleanup.
- 111Project: Live SearchFilter a list as the user types.
- 112Derived StateCompute values during render instead of storing duplicates.
- 113StrictModeStrictMode double runs some code in development to reveal bugs.
- 114Common MistakesAvoid mutating state, missing keys, stale closures and effect loops.
- 115AccessibilityUse semantic tags, labels and aria attributes.
- 116Testing ComponentsRender a component and assert on what the user sees.
- 117Project StructureGroup by feature, keep components small and name files after components.
- 118Starting a ProjectVite creates a fast React project.
- 119Environment VariablesVite exposes variables that start with VITE_ to the browser.
- 120Why Not Index KeysIndex keys break state when a list reorders.
- 121Event BubblingEvents bubble to parents.
- 122Actions and useNewer React lets forms call functions directly and use reads promises.