@primer/react
Version:
An implementation of GitHub's Primer Design System using React
16 lines • 792 B
TypeScript
import React from 'react';
/**
* A hook that caches tree items to avoid expensive querySelectorAll calls on every keypress.
* The cache is invalidated when the tree structure changes (via MutationObserver).
*
* PERFORMANCE: This is critical for INP because querySelectorAll('[role="treeitem"]')
* on large trees can take 10-50ms, which directly blocks user input response.
*
* Note: useRovingTabIndex also uses querySelectorAll for Home/End/PageUp/PageDown navigation,
* but those are infrequent single keypresses. Typeahead fires on every character typed,
* making it the priority optimization target.
*/
export declare function useTreeItemCache(containerRef: React.RefObject<HTMLElement>): {
getTreeItems: () => HTMLElement[];
};
//# sourceMappingURL=useTreeItemCache.d.ts.map