React Data Inspector
Documentation / Core behavior

Search

Search collapsed data with explicit work limits.

Search collapsed data

searchable adds a query field, result count, and next/previous controls. Search visits collapsed branches in yielding tasks; choosing a result requests the ancestor expansion needed to reveal it.

import { DataInspector } from '@nipe-solutions/react-data-inspector'

export function Searchable() {
  return (
    <DataInspector
      value={{ users: [{ name: 'Ada' }, { name: 'Lin' }] }}
      searchable
      searchOptions={{
        scope: 'keys-and-values',
        maxNodes: 50_000,
        maxResults: 500,
      }}
    />
  )
}

Matching is case-insensitive text containment. scope chooses keys, values, or both; arbitrary objects are not passed through an unsafe stringify operation. Custom types may supply their own search text.

Defaults and work limits

OptionDefaultUpper bound
scopekeys-and-valueskeys, values, or keys-and-values
debounce150 msDelay before a changed query starts
maxNodes100,0001,000,000
maxResults1,00010,000
stringLimit65,536 characters100,000 characters

Depth, collection, and other inspection limits also apply. Counts disclose incomplete results when a work limit or truncation prevents a complete answer. A partial count is not a total count of matching values in the graph.

Control the query

Pass searchQuery and onSearchQueryChange when another application control owns the query. An empty string is a controlled empty query; omitting the prop leaves the query uncontrolled. Keep that choice stable during a mount.

Query changes cancel the previous scan. Cancellation happens between bounded tasks; it cannot interrupt a synchronous Proxy trap or application callback already executing.

Data updates and refreshing results

Search is not an atomic snapshot of application state.

  • New data generations coalesce into a follow-up scan without restarting the query debounce.
  • Completed results remain usable while the localizable refreshing status reports an update.
  • A match can become stale before it is revealed. Reveal resolves against the current value and can report an unavailable target.
  • Mutating a shared object during a scan does not create snapshot isolation.

See controlled state for external updates and ownership.

Shared references and reveal

Search can revisit a shared subtree at a shallower path when a previous occurrence hid descendants behind the depth limit. Its discovery order can differ from normal visible rendering; it does not promise every possible alias path as a separate result.

Reveal requests required expansion and checks the current target. In controlled mode, the parent must accept the expansion request. Row and depth limits can prevent a result from becoming visible even when it was found.

Keyboard and custom callbacks

In the search field, Enter moves to the next result and Shift+Enter moves to the previous result. Next/previous buttons provide the same operation. Result counts and refresh state have accessible status text.

Keep custom searchText, matchers, and child sources pure and bounded. Their synchronous work cannot be preempted. See custom types, safe inspection, and large-data configuration.