Skip to content
tezvyn:

All bites

The whole library, newest first. Filter by what you are here for, or pick a topic if you already know.

4330 bites

Page 17

Design a multi-step wizard form pattern in React
React & Next.js2 min read

Design a multi-step wizard form pattern in React

Shared state, step validation, and resilient navigation. A great answer uses one form instance with per-step Zod schemas, a context stepper, and localStorage persistence. Red flag: isolated forms per step that lose data on navigation.

Explain the difference between React.memo and useMemo
React & Next.js2 min read

Explain the difference between React.memo and useMemo

React.memo skips re-renders when props match; useMemo caches a computed value between renders.

Child re-renders with unchanged props: function identity and useCallback fix
React & Next.js2 min read

Child re-renders with unchanged props: function identity and useCallback fix

This tests reference equality and React memoization. A strong answer says inline functions recreate on every parent render, breaking React.memo, and uses useCallback with a correct dependency array. A red flag is ignoring identity or omitting dependencies.

How would you use React Profiler to find unnecessary re-renders?
React & Next.js2 min read

How would you use React Profiler to find unnecessary re-renders?

This tests the Profiler for wasted renders. A good answer covers wrapping a subtree in Profiler, comparing actualDuration to baseDuration on updates, and checking for missing memoization. Red flag: mentioning only the browser extension without timing metrics.

When can overusing useMemo hurt performance and what are the trade-offs?
React & Next.js2 min read

When can overusing useMemo hurt performance and what are the trade-offs?

Memoizing cheap work wastes cycles, increases memory use, and burdens dependency tracking.

How do React.lazy and dynamic import() enable code splitting?
React & Next.js2 min read

How do React.lazy and dynamic import() enable code splitting?

It tests your grasp of React code-splitting and the Suspense contract. A strong answer states that lazy defers loading until first render via dynamic import, and Suspense shows a fallback while the Promise resolves.

React & Next.js2 min read

How does Next.js routing auto-implement code splitting?

Tests route-based code splitting versus manual setup. Strong answers note each page/route becomes its own chunk automatically, while client-only apps need explicit React.lazy and Suspense.

React Profiler long render duration: causes and next steps?
React & Next.js2 min read

React Profiler long render duration: causes and next steps?

Tests interpreting actualDuration vs baseDuration. Outline: close values on updates mean broken memoization—add memo or useMemo; high baseDuration alone means an inherently slow subtree. Red flag: proposing fixes before comparing these two Profiler metrics.

How would you avoid new functions per list item without useCallback?
React & Next.js2 min read

How would you avoid new functions per list item without useCallback?

Tests stable handler patterns for large lists. Answer: define one handler outside the map, attach it to every item, and read the id from a data-id attribute via currentTarget.dataset.id. Or use event delegation on the parent. Red flag: useCallback in loop.

React & Next.js2 min read

Explain list virtualization and when it beats React.memo

This tests whether you know React.memo skips re-renders but leaves off-screen nodes in the DOM. A strong answer describes virtualization mounting only visible items to cut memory use. A red flag is claiming memoization fixes jank or saves memory for big lists.

React & Next.js2 min read

When would you choose Redux or Zustand over React's built-in hooks?

Choose global state when many components share rapidly changing state, logic is complex, or updates must be traceable.

React & Next.js2 min read

How do Redux actions, reducers, and click-to-render data flow work?

Tests Redux unidirectional flow and immutability. Strong answer: actions are plain event objects, reducers are pure functions returning new state, and flow goes dispatch to store to UI. Red flag: actions mutating state or reducers with side effects.

React & Next.js2 min read

How do you select a single property and prevent extra re-renders?

Tests selector granularity and reference equality in subscriptions. Great answer: return a primitive via a focused selector; for objects, memoize with createSelector or pass shallowEqual. Red flag: reaching for useMemo or React.memo before fixing the selector.

React & Next.js2 min read

How would you handle an async API call in Redux Toolkit versus Zustand?

Tests structured async state machines versus lightweight patterns. A strong answer contrasts createAsyncThunk's pending/fulfilled/rejected lifecycles with Zustand's direct set() in async functions, noting Redux's traceability trade-off.

Explain atomic state management and how it differs from Redux
React & Next.js2 min read

Explain atomic state management and how it differs from Redux

This tests bottom-up vs top-down architecture. Good response contrasts atom graphs with Redux's monolithic store, notes atoms avoid extra rerenders sans selectors, and flags granular subscriptions.

React & Next.js3 min read

What is state hydration in Next.js SSR with Redux or Zustand?

Hydration attaches listeners to server HTML; serialize state to an escaped script tag; boot client store before React or markup is discarded.

React & Next.js2 min read

How does React Testing Library's guiding principle influence query choice?

This tests whether you prioritize user-visible attributes over implementation details when selecting queries. A strong answer ranks getByRole, label, and text above testId because users interact with meaning, not data attributes.

How would you unit test a React title component?
React & Next.js2 min read

How would you unit test a React title component?

This tests React Testing Library's user-centric approach and Jest basics. A strong answer renders the component, queries the h1 by role or text, and asserts it is in the document. A red flag is using Enzyme shallow rendering or testing internal state.

React & Next.js2 min read

What are fireEvent and user-event, and why prefer user-event?

FireEvent triggers single DOM events; user-event simulates full interactions with focus checks. Prefer user-event.

React & Next.js2 min read

Test a React component fetching async data on mount

Whether you can assert on asynchronous DOM updates without race conditions. Mock the API, render, then use findBy or waitFor to assert on loading and loaded states. Red flag: using getBy right after render or forgetting to await async queries.