Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk5 min

React Search, Filters, and Pagination: What to Calculate

Keep search, filter, sort, and page choices as inputs; derive the displayed list from them instead of synchronizing a second result array in state.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use useState for the choices a person makes—such as a search query, selected category, sort order, or page number. For a modest client-side list, calculate the filtered, sorted, and paginated rows from those choices while rendering instead of keeping a second copy of the results in state. That avoids having to keep two versions of the same data synchronized.

What belongs in state—and what should be calculated?

React recommends keeping state minimal: if a value can be calculated from props or existing state during rendering, it usually does not need its own state variable. Its state-structure guidance warns against redundant state, and its Thinking in React example stores the search query and selected filter while calculating the filtered products.

As an Amazon Associate I earn from qualifying purchases.

For a list view, the distinction is between the inputs and the result. Keep the source data where it belongs, and keep the user’s current choices. Derive the rows shown on screen from those values.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • State or URL values: search text, selected filters, sort direction, and current page—when the user can change them.
  • Derived values: matching rows, sorted rows, page count, and the slice displayed on the current page.

Storing both the controls and a filtered array that can be recomputed from them creates a synchronization obligation: every relevant change must update both. Calculate the result instead, unless it represents independently changing data.

#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

How do you filter and paginate without storing the results?

Apply the transformations in order: filter the source collection, sort the matches, then select the requested page. The following example keeps the query, category, and page as state, while the result arrays and count are render-time calculations.

const [query, setQuery] = useState("");
const [category, setCategory] = useState("all");
const [page, setPage] = useState(1);

const pageSize = 20;
const normalizedQuery = query.trim().toLowerCase();

const filteredItems = items.filter(item => {
  const matchesQuery = item.name.toLowerCase().includes(normalizedQuery);
  const matchesCategory = category === "all" || item.category === category;
  return matchesQuery && matchesCategory;
});

const sortedItems = [...filteredItems].sort((a, b) =>
  a.name.localeCompare(b.name)
);

const pageCount = Math.ceil(sortedItems.length / pageSize);
const safePage = Math.min(page, Math.max(1, pageCount));
const visibleItems = sortedItems.slice(
  (safePage - 1) * pageSize,
  safePage * pageSize
);

Render visibleItems and use safePage for pagination controls. The spread before sort() matters: sorting a copied array avoids mutating the filtered array or the original source collection. If the list is empty, pageCount is zero and safePage becomes 1; render an empty state and disable or omit page navigation rather than implying there are results.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

Keep the page valid when the controls change

When a new query or filter should start from the first page, reset the page as part of the same user interaction:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
function handleQueryChange(event) {
  setQuery(event.target.value);
  setPage(1);
}

function handleCategoryChange(event) {
  setCategory(event.target.value);
  setPage(1);
}

Resetting on a control change is a design choice; clamping with safePage also protects against the result count shrinking after data changes. Without one of these safeguards, the selected page can lie beyond the new result set and make a nonempty list appear empty.

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

Should search, filters, and pagination live in the URL?

Use URL search parameters for view choices that should survive refresh, be shareable, or participate in browser history. Keep them in component state when they are temporary and only need to last for the current view. A common hybrid is a local input draft that updates on every keystroke, with the URL value committed on submit or through a deliberate debounce strategy.

Where the value lives Useful when Trade-off
Component state The choice is temporary and local to the current view. It does not, by itself, survive a refresh or provide a shareable link.
URL search parameters The view should be bookmarkable, shareable, refresh-safe, or restorable through browser history. Updating parameters with React Router navigates, so choose when and how often to commit changes.
Server request driven by URL values The collection is large or server-owned, and the server should return the matching page or results. The right split depends on the app’s data ownership and request architecture.

React Router’s useSearchParams reference documents reading and setting query parameters; the setter causes navigation. Its state-management guide and Address Book tutorial show URL-driven search, including a GET form and loader-based filtering. A GET form is a straightforward option when submitting the search should navigate to a URL containing the form values.

Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor | 100Hz, Game Mode, Advanced Eye Comfort, HDMI and D-sub Ports (LS27D366GANXZA)
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

Update search parameters deliberately

For React Router versions whose API reference imports from react-router, a basic pattern is:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import { useSearchParams } from "react-router";

function ItemSearch() {
  const [searchParams, setSearchParams] = useSearchParams();
  const query = searchParams.get("q") ?? "";

  function submitSearch(event) {
    event.preventDefault();
    const formData = new FormData(event.currentTarget);
    const nextParams = new URLSearchParams(searchParams);
    const nextQuery = String(formData.get("q") ?? "").trim();

    if (nextQuery) {
      nextParams.set("q", nextQuery);
    } else {
      nextParams.delete("q");
    }

    nextParams.delete("page");
    setSearchParams(nextParams);
  }

  return (
    <form onSubmit={submitSearch}>
      <input name="q" defaultValue={query} />
      <button type="submit">Search</button>
    </form>
  );
}

Check the import path and API for the React Router major version used by your application. The current reference notes two important differences from React state setters: callback-form updates do not queue and build on each other like React’s state updates, and the returned URLSearchParams object is mutable. Do not mutate that object and expect the URL to update; create a copy and pass it to the setter. When multiple parameter edits depend on one another, perform them together in a single update.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.

Because URL updates navigate, submitting a search can preserve a useful boundary between a draft and the committed view. The address book example also demonstrates normal browser navigation through earlier searches. For a controlled draft that must respond when the URL changes through browser Back or Forward, synchronize it intentionally with the committed URL value; avoid adding an effect that mirrors values without a defined synchronization need.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When is useMemo useful for list calculations?

useMemo is an optimization, not a substitute for state and not a correctness requirement. React describes it as caching a calculation’s result between renders. It does not make the first calculation faster, and React recommends using it only for specific situations, such as an observed expensive calculation or when stable identity helps a memoized child. See the useMemo reference.

Start with ordinary filtering, sorting, and slicing during render. If profiling shows that a transform is expensive, or that a changed array identity is causing a memoized consumer to do avoidable work, memoize the calculation using every reactive input it depends on. Do not add it automatically to make derived data correct; the calculation should produce the right output without a cache.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Where should filtering and pagination happen for large data?

Client-side derivation is a natural fit when the component owns a modest collection that is already available locally. For large or server-owned collections, requesting a filtered and paginated slice from the server may fit better than downloading and processing the entire collection in the browser. React Router’s loader example illustrates URL-driven data loading, but the division of work depends on the application’s data architecture.

Whichever side performs the work, keep the roles clear: query, filters, sort choice, and page are inputs; the rows and page count are results of those inputs and the current data. Persist the inputs where their intended lifetime belongs, and avoid a separately synchronized result copy unless it has an independent source of change.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.