aws / aws/graph-explorer

Memoize useSearchableAttributes to stop per-render scan-and-sort

Open
#2,088 0 comments 0 reactions 0 assignees View on GitHub
ready-for-agent
Dominant language
TypeScript
Stars
481
Forks
108
Avg merge
8d 9h
Merged PRs (30d)
7

Description

## Parent

- Part of #2086

## What to build

Stop `useSearchableAttributes` from recomputing a full scan-and-sort of searchable attributes on every render. Memoize it (via `useMemo` keyed on its inputs, or convert it to a Jotai `atomFamily` keyed by vertex type) so it caches like the other display-config selectors. No user-visible UI change on its own; this removes the per-keystroke hot-path cost the attribute picker depends on.

## Acceptance criteria

- [ ] `useSearchableAttributes` no longer allocates/scans/sorts on every render when inputs are unchanged
- [ ] Hook test on a large schema asserts the returned array is referentially stable across re-renders with unchanged inputs
- [ ] `pnpm checks` and `pnpm test` pass

## Blocked by

- None — can start immediately.

Contributor guide

Open the contributing guide

Research direction

Start at the useSearchableAttributes hook and its hook test; inspect how the searchable attributes are scanned and sorted and identify the inputs that control the result. Add the large-schema referential-stability assertion, then run pnpm checks and pnpm test; done means unchanged inputs return the same array without repeated scan-and-sort work.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend, performance
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.