JSX Errors: Unexpected Token, Invalid Children, and Other Fixes
JSX errors are terse but consistent. Learn what unexpected token and invalid children mean, plus the fixes for the most common JSX syntax mistakes.
Build modern UIs with React
JSX errors are terse but consistent. Learn what unexpected token and invalid children mean, plus the fixes for the most common JSX syntax mistakes.
React components are JavaScript functions that turn inputs called props into reusable UI. Learn how function components work and how to compose them.
Props let a parent component pass data down to its children. Learn how to pass props in React, read them with destructuring, and set default values.
Lifting state up moves shared state to a common parent. Follow a step-by-step example to share one value between two React components.
A parent controls a child component by owning its value and passing it down as props. Learn the controlled component pattern in React.
A component re-renders when its state changes or a parent re-renders. Learn the causes and trace them with the React DevTools Profiler.
Type React props with an interface or type alias. Learn inline types, optional props, and union types for TypeScript components.
React.ComponentProps extracts the props type of an element or component. Learn to reuse and extend existing prop types instead of rewriting them.
Build polymorphic React components that render as any element with an as prop. Type the pattern with ElementType and generics in TypeScript.
Update objects in React state by replacing them with new copies instead of mutating. Use the spread syntax for flat fields and nested updates.
React batches state updates by waiting for an event handler to finish, then applying every change in one re-render. See how batching works.
Combine useReducer with context to share reducer state and dispatch down the tree without prop drilling, using a provider and small custom hooks.