Skip to content
tezvyn:

Components

78 bites tagged Components — interview questions with model answers, and 60-second explainers.

Vue, Angular & Svelte2 min read

Angular: Dynamic Component Loading

Programmatically create and render components anywhere in your app, not just where you've hardcoded them. Use it for dynamic dashboards or modal dialogs. The footgun is forgetting to manually destroy components, which leads to memory leaks.

Vue, Angular & Svelte2 min read

Angular View Encapsulation: Walling Off Your Component Styles

View Encapsulation walls off a component's CSS to prevent styles from leaking in or out. By default, Angular emulates a Shadow DOM to scope styles, but you can change this. The footgun is using `None` to fix a style, creating global CSS conflicts.

Vue, Angular & Svelte2 min read

Svelte Slot Props: Child Informs, Parent Renders

Svelte slot props let a child component pass data up to its parent's slot. This is key for reusable list components where the child provides data for each item, but the parent controls the rendering. The footgun: the `let:` directive goes on the component tag.

Vue, Angular & Svelte2 min read

Angular Content Projection with ng-content

ng-content creates a "slot" in a component's template, letting you project parent content into it. Use this for reusable wrappers like cards or dialogs. The key footgun: never use @if on ng-content, as the content is always rendered, even if hidden.

Vue, Angular & Svelte2 min read

Vue Slots: Projecting Content into Components

Think of a Vue slot as a picture frame: the child component defines the frame, and the parent provides the picture. This is used for reusable layouts or buttons where the structure is fixed but the content is dynamic.

Vue, Angular & Svelte2 min read

Angular's input() Function: Passing Data to Components

Angular's input() function lets a parent pass data to a child, defining the child's public API. Use it to configure a component, like passing a `value` to a slider. The footgun: the returned signal is read-only; the child cannot modify its own input.

Vue, Angular & Svelte2 min read

Vue Component Props: Passing Data Downstream

Think of props as a component's 'arguments.' They let a parent pass data down to a child, making it reusable. Use them to pass dynamic data like a user's name to a profile card. The footgun: never mutate a prop directly inside the child component.

Vue, Angular & Svelte2 min read

Vue Single-File Components (SFCs)

Vue Single-File Components (.vue files) colocate a component's template, logic, and styling into one modular unit. This is the standard for building Vue SPAs and static sites, enabling scoped CSS and pre-compiled templates. Remember, SFCs require a build step.

UI Design & Figma2 min read

Base Component Pattern: Your Design System's Template

Think of a base component as a master template for UI elements. Changes to the master instantly update every copy, ensuring consistency. Use it for repeated elements like buttons or icons that need slight variations.

UI Design & Figma2 min read

Figma Instance Overrides: Local Changes, Global Components

Instance overrides let you customize a component copy without breaking its link to the main. Use them to change a button's text or swap an icon for a specific context. The footgun: Overrides are lost when swapping variants if layer names don't match.

UI Design & Figma2 min read

Figma's Slot Pattern: Flexible Components Without Detaching

Think of a slot as a 'bring your own content' area within a Figma component. It lets you customize instances with unique layouts, like in a card or modal, without detaching them from the main component and breaking your design system.

UI Design & Figma2 min read

Breaking the Link: Detaching Figma Instances

Detaching an instance in Figma permanently breaks its link to the main component, converting it into a standard frame. Use this to make changes overrides can't handle or to create a new component variation.

UI Design & Figma2 min read

Figma Libraries: Your Team's Single Source of Truth

A Figma library is your team's shared toolbox, ensuring everyone uses the same approved components. Use it to distribute your design system across files. The footgun is forgetting to publish updates, leaving teammates with outdated, inconsistent designs.

UI Design & Figma2 min read

Instance Swap Properties: Control Nested Components

An instance swap property is like a designated parking spot for a nested component. It tells designers 'you can swap this part out' and provides recommended replacements, like swapping an icon in a button.

UI Design & Figma2 min read

Nesting Components: Building Systems, Not Just Screens

Nesting components is like building with Lego: you combine small, reusable pieces (icons, buttons) into larger structures (cards). This is key for scalable design systems, where a card might contain nested icon and button instances.

UI Design & Figma2 min read

Figma Components: Main vs. Instance

Think of a main component as a cookie cutter and instances as the cookies. The main component defines the master design (e.g., a button's shape). Instances are linked copies you use everywhere.

React & Next.js2 min read

React Error Boundaries: Containing UI Crashes

An Error Boundary is like a try...catch block for React components, preventing a single UI crash from breaking your whole app. Use it to wrap components that might fail, showing a fallback UI instead of a white screen.

React & Next.js2 min read

React.memo: Skip Unnecessary Component Renders

React.memo tells a component to skip re-rendering if its props are the same as last time. Use it to prevent costly renders when a parent updates. The footgun is passing new objects or functions as props, which breaks the default shallow comparison.

React & Next.js2 min read

Typing React Component Props with TypeScript

Use TypeScript to define a 'contract' for your component's props with an `interface` or `type`. This catches bugs by ensuring data passed to a component has the correct shape. The footgun: files with JSX must use the `.tsx` extension.

React & Next.js2 min read

Compound Components: Build Flexible APIs via Shared State

Think of HTML's `<select>` and `<option>`. The Compound Component pattern lets a parent manage state while children act as declarative configuration. It's used for flexible UI like tabs or accordions.

React & Next.js2 min read

React's Controlled vs. Uncontrolled Components

A controlled component is a form input whose value is driven by React state; an uncontrolled component lets the DOM manage its own state. Use controlled for instant validation or conditional logic.

React & Next.js2 min read

React's Rule: Favor Composition Over Inheritance

Instead of extending a base component, build complex UIs by wrapping and configuring smaller ones. Use this for generic containers like dialogs or for creating specialized versions of a component.

React & Next.js1 min read

React Fragments: Group Elements Without a Wrapper

React Fragments let you group multiple elements without adding an extra `<div>` to the DOM. Use them when a component needs to return adjacent elements, like table cells (`<td>`).

React & Next.js2 min read

React Props: Arguments for Your Components

Think of props as arguments for your UI components, letting you pass data from a parent down to a child. You use them to customize a component's appearance or behavior, like passing a user object to a `ProfileCard`.

Get Components bites daily.

Five a day, five minutes, offline. With quizzes so it sticks.

Open testing — you’ll join as an early tester.