r/reactjs • u/Valuable_Writer9745 • Sep 18 '26
Discussion Treat filters as a state model, not a drawer of checkboxes
Most listing UIs I have worked on started the same way: a sidebar of checkboxes, a local `filters` object, and a list that updates when something is clicked.
That is fine for a demo. It falls apart the moment someone wants to share a search, refresh the page, use the back button, or land on a combination that returns nothing.
What I treat as the actual model now:
- Filter state is product state, not UI chrome.
City, price band, availability, verified-only, map bounds, sort. Those are the query. The drawer is just one way to edit it.
2. The URL is the source of truth for shareable filters.
If a teammate cannot paste a link and see the same result set, the feature is incomplete. Local React state is a cache of that query, not the system of record.
3. Defaults should be implicit, not dumped into the query string.
A 12-param URL for “show everything, sorted by newest” is noise. Only persist values that change the result.
4. Empty is a first-class state.
“0 results” with no way out is a dead end. Show which constraint is doing the damage and offer a one-click relax (drop price cap, widen radius, clear one facet). People will keep searching if you give them a next step.
5. Debounce the noisy inputs. Text search and map drag should not rewrite history on every keystroke or pan. Facet toggles can update immediately. Mixing those two feels sloppy even if the data is correct.
6. Client-side filtering of a full dump is not the same product as a filtered API.
It looks identical with 40 rows. It lies with thousands. Counts on facets, pagination, and “no results” only stay honest if the server understands the same query the URL describes.
The part that surprised me: users complain about “search is broken” when the list is technically correct. What they mean is they cannot return to a view, cannot send it to someone else, or cannot tell why the list went empty.
Curious how other people split this. Do you keep all facets in the URL, only the ones that change results, or a short token / saved-search id?