tezvyn:

🌐Frontend Dev

Frontend web development and UI engineering

498 bites

TypeScript & Web APIs30 sec read

DOM Traversal: Navigating the HTML Tree

DOM traversal is navigating a family tree of HTML nodes. You move between elements using properties like `parentNode` and `nextSibling`. This is key for finding elements relative to a known start point.

TypeScript & Web APIs30 sec read

DOM Manipulation: Treating Your Webpage Like a Live Object

The DOM is a live tree of your webpage's HTML. DOM manipulation is how JavaScript changes that tree—adding, removing, or updating elements. This is key for all interactive web development. The footgun: direct, frequent manipulation is slow.

TypeScript & Web APIs30 sec read

Web Storage API: Browser Key-Value Stores

Web Storage provides simple browser key-value stores: `localStorage` and `sessionStorage`. Use `localStorage` for data that persists across sessions, like user settings, and `sessionStorage` for data tied to a single tab.

TypeScript & Web APIs30 sec read

The DOM: Your HTML as a Live Object Tree

The DOM is the browser's live model of a webpage, represented as a tree of objects. JavaScript uses it to find elements, change content, and react to clicks. The footgun: DOM changes are in-memory; they don't edit the original HTML file on the server.

TypeScript & Web APIs32 sec read

The `document` Object: Your Page's API

The `document` object is the root of the DOM tree, representing the entire webpage in your script. Use it to find elements (`getElementById`), create new ones (`createElement`), or read page info. The main footgun: accessing an element before it's been parsed.

TypeScript & Web APIs30 sec read

The `window` Object: Your Browser's Global Scope

Think of the `window` object as the global stage for your JavaScript. It represents the browser tab and holds all global variables and APIs like `fetch` and `setTimeout`. You use it constantly, often implicitly.

React & Next.js32 sec read

Zustand's `create`: A Factory for Global State Hooks

Zustand's `create` function is a factory for your global state. You define your state and actions, and it returns a custom hook to access them anywhere in your app, avoiding prop drilling. The footgun: `set` shallow-merges state by default.

React & Next.js30 sec read

React State Updates: The Queue and the Updater Function

React batches state updates from one event, like a waiter taking a full order before heading to the kitchen. This prevents multiple re-renders. The footgun: `setCount(count + 1)` called three times only increments once, as `count` is fixed for that render.

React & Next.js30 sec read

React's Two-Step Update: Render and Commit

React updates the screen in two phases. The "render" phase is React calling your components to calculate the UI. The "commit" phase is when it actually updates the DOM. The footgun is thinking rendering always changes the screen; it's just the prep work.

React & Next.js30 sec read

React's Concurrent Rendering: Interruptible UI Updates

Concurrent Rendering lets React pause and resume rendering, so a large update won't freeze the UI. It's like a chef pausing a big task to handle a quick order, ensuring the app stays responsive. This is key for features like Suspense.

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

React Hydration: Bringing Server HTML to Life

Hydration turns static, server-rendered HTML into a fully interactive React app. It's the core of Server-Side Rendering (SSR), where the client "wakes up" the initial HTML by attaching event listeners.

React & Next.js30 sec read

cy.intercept: Control Network Traffic in Cypress Tests

cy.intercept acts like a programmable proxy in your Cypress tests, letting you watch, modify, or fake network requests. Use it to test loading states or error handling without a live backend. Footgun: intercepts are cleared before each test, not just once.

React & Next.js30 sec read

MSW: Mock APIs at the Network Layer

Mock Service Worker intercepts API calls at the network level using a Service Worker, so your app makes real requests. Use it for consistent mocking in development, testing, and Storybook.

React & Next.js30 sec read

Snapshot Testing: Lock In Your UI's Rendered Output

Snapshot testing catches unintended UI changes by comparing a component's rendered output to a saved 'golden' version. Use it to ensure UIs don't break during refactors. The biggest footgun is blindly updating snapshots, which can approve bugs as correct.

React & Next.js30 sec read

Jest Mocks: Spies for Your Functions

A Jest mock is a spy that watches a function, recording calls without running the original logic. This lets you isolate code under test, verify interactions like callbacks, and control return values. The footgun is assuming mocks run real logic—they don't.

React & Next.js30 sec read

Jest Matchers: Asserting Values in Your Tests

Jest matchers are assertion functions that check if a value meets a condition. You use them with `expect()` to verify function outputs, object properties, or promise states.

React & Next.js30 sec read

Jest: The 'Batteries-Included' JavaScript Test Runner

Jest is a "batteries-included" JavaScript testing framework, bundling a runner, assertions, and mocking tools. It's a default for React apps but works for any JS project. The footgun is thinking it's only for React; it's a general-purpose tool.

React & Next.js30 sec read

Test Like a User: The React Testing Library Philosophy

React Testing Library's philosophy is to test components the way a user interacts with them, not by their internal implementation. This ensures refactors don't break tests. The footgun is querying by implementation details instead of what a user actually sees.

React & Next.js30 sec read

Jotai Derived Atoms: Computed State from Other Atoms

Think of a derived atom like a spreadsheet formula: its value is computed from other atoms. Use it for reactive values like a cart total from item prices. The footgun: the `get` in your read function is reactive, but the `get` in your write function.