conditional rendering
Showing different JSX depending on a condition, using an if statement, the && operator or the conditional (ternary) operator.
In more detail
For example {isOpen && <Modal />} renders the modal only when isOpen is true. Conditionally rendering a lazy component is how interaction-based code splitting loads it on demand.
Related terms
- JSX — The HTML-like syntax used in React code, such as <Button size="lg">Save</Button>, which compiles to JavaScript function calls.
- React.lazy — The React function that defines a component whose code is loaded with a dynamic import the first time it renders.
Taught in
- Compound Components: Inversion of Control with Context — React 19 & Modern Component Architecture
- Slot Patterns And Headless UI Architecture in React — React 19 & Modern Component Architecture
- Code-Splitting with React.lazy: Dynamic Imports And Chunks — React 19 & Modern Component Architecture