destructuring
JavaScript syntax that unpacks values from an object or array into separate named variables in one step.
In more detail
const { title, count } = props takes two properties out of props, and const [count, setCount] = useState(0) takes the two items of the returned array. Components usually destructure their props right in the parameter list, which is also where defaults are set.
Related terms
- tuple — An ordered, fixed-length group of values in which each position can have its own meaning and type.
- useState — The React hook that adds a state variable to a component and returns the current value with a function to change it.
- spread syntax — The three-dot JavaScript syntax that copies the items of an array or the properties of an object into a new one.
- default prop value — A value a component uses for a prop when the caller leaves that prop out.
Taught in
- Error Boundaries: Nested error.tsx & Reset Logic — Next.js 15 & Modern App Router Architecture
- Async Data Fetching: Parallel Requests & Preloading — Next.js 15 & Modern App Router Architecture
- Props Contract: Immutability, Children, And Polymorphic Tags — React 19 & Modern Component Architecture
- Custom Hook Composition: Encapsulating Reactive Logic — React 19 & Modern Component Architecture
- Tuples: Fixed Length, Labeled Elements And Variadic Tuples — Production TypeScript