tezvyn:

🌐Frontend Dev

Frontend web development and UI engineering

498 bites

React & Next.js30 sec read

useMemo: Cache Expensive Calculations in React

The useMemo hook caches a function's return value, preventing slow calculations from running on every render. Use it to skip heavy data filtering unless its inputs change. The main footgun is a missing dependency, which leads to stale, cached data.

React & Next.js30 sec read

React's useCallback: Cache Functions, Not Just Values

useCallback gives you the same function instance across re-renders, as long as its dependencies are stable. This is key for optimizing child components with React.memo or preventing useEffect from re-running.

React & Next.js30 sec read

The useReducer Hook: Predictable State Updates

useReducer is a state machine for your components, managing complex state changes predictably. Use it when state logic is complex or the next state depends on the previous one, like in a shopping cart.

React & Next.js31 sec read

Custom Hooks: Package Component Logic for Reuse

A custom hook packages stateful logic (like useState and useEffect) into a reusable function. Use one when multiple components need the same logic, like tracking online status for a status bar and a save button. Footgun: Names must start with `use`.

React & Next.js30 sec read

React Refs: Memory Without Re-renders

A React ref is like a secret pocket for your component to remember information without triggering re-renders. Use it to hold values not needed for rendering, like a timer ID. The footgun: changing a ref's value won't update the UI; use state for that.

React & Next.js33 sec read

Thinking in React: Decomposing UIs into Components

Think of UIs not as one big page, but as a tree of reusable components. Start by breaking a design mockup into a hierarchy of pieces. The footgun is creating 'god components' that do too much; each component should have a single responsibility.

React & Next.js30 sec read

useEffect: Syncing React with the Outside World

useEffect synchronizes your component with systems outside React's control, acting as a bridge to the browser or network. It's for data fetching or subscriptions.

React & Next.js30 sec read

Conditional Rendering: Show UI Based on State

React uses plain JavaScript to decide what UI to show, which is essential for displaying loading states, errors, or user-specific content. The footgun: `count && <Component />` will render a "0" if `count` is 0, not nothing.

React & Next.js30 sec read

React Events: Pass, Don't Call

React handles user actions with event handler functions passed as props, like `onClick={handleClick}`. This is how you make buttons or forms interactive. The key mistake is calling the function (`onClick={doIt()}`), which runs on render, not on click.

React & Next.js30 sec read

useState: Giving Components Memory

useState gives a component its own memory, letting it track information that changes over time. It's used for everything from handling form input to toggling UI. The biggest footgun: state updates are asynchronous and only apply on the next render.

React & Next.js30 sec 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.js30 sec 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`.

React & Next.js30 sec read

JSX: Putting HTML Inside Your JavaScript Components

JSX is a syntax extension that lets you write HTML-like markup directly inside your JavaScript files, keeping UI logic and structure together. It's the standard way to define a React component's output. The footgun is that JSX is stricter than HTML.

React & Next.js30 sec read

React Components: Your UI Building Blocks

Think of React Components as custom, reusable HTML tags you create with JavaScript functions. Use them to build everything from buttons to page layouts, speeding up development.

CSS & Design Systems30 sec read

Component Usage Guidelines: The Manual for Your Design System

Usage guidelines are the instruction manual for your design system, ensuring consistency. They prevent developers from guessing button states and designers from stretching logos.

CSS & Design Systems30 sec read

Bundle Size: When Runtime Dependencies Defeat Tree Shaking

Tree Shaking is static, but your app is dynamic. It can fail when a component imports a large dependency for an optional, runtime-configured feature. A UI library's provider might pull in an entire form library, even if you don't use it.

CSS & Design Systems30 sec read

Atomic CSS: Styling with Single-Purpose Utilities

Atomic CSS builds interfaces with tiny, single-purpose classes directly in your HTML, like using LEGO bricks for styling. It's the core of frameworks like Tailwind CSS, letting you build UIs without writing custom CSS. The footgun is creating unreadable HTML.

CSS & Design Systems30 sec read

Design System Metrics: Proving Its Worth

Prove your design system's value with data, showing it's a force multiplier, not just a library. Track metrics like component adoption and faster time-to-market to justify budget and guide your roadmap. The footgun: avoid vanity metrics like component count.

CSS & Design Systems30 sec read

Versioning Design Systems: Holistic vs. Incremental

Versioning a design system is about communicating change. Use Semantic Versioning (MAJOR.MINOR.PATCH) to signal update impact. This prevents teams from using outdated components, ensuring consistency.

CSS & Design Systems30 sec read

Design System Governance: Preventing UI Chaos

A design system governance model defines the rules for evolving your UI library, preventing a free-for-all of conflicting changes. It dictates how new components are proposed and approved.