facebook/react · warning
Invalid index ${index} specified; store contains ${this.numE
Error message
Invalid index ${index} specified; store contains ${this.numElements} items. What it means
Store.getElementAtIndex(index) (packages/react-devtools-shared/src/devtools/store.js) maps a flat index (used by the virtualized Components tree) to an Element by walking roots and weights. If index is negative or >= numElements (the total weight across roots), the index points past the current tree, so it warns and returns null. This happens when the tree shrank between deriving the index and reading it (a store mutation landed mid-render).
Source
Thrown at packages/react-devtools-shared/src/devtools/store.js:614
get unsupportedBridgeProtocolDetected(): boolean {
return this._unsupportedBridgeProtocolDetected;
}
get unsupportedRendererVersionDetected(): boolean {
return this._unsupportedRendererVersionDetected;
}
get lastSelectedHostInstanceElementId(): Element['id'] | null {
return this._lastSelectedHostInstanceElementId;
}
containsElement(id: number): boolean {
return this._idToElement.has(id);
}
getElementAtIndex(index: number): Element | null {
if (index < 0 || index >= this.numElements) {
console.warn(
`Invalid index ${index} specified; store contains ${this.numElements} items.`,
);
return null;
}
// Find which root this element is in...
let root;
let rootWeight = 0;
for (let i = 0; i < this._roots.length; i++) {
const rootID = this._roots[i];
root = this._idToElement.get(rootID);
if (root === undefined) {
// We should never reach this. This is a bug in the backend renderer.
return this._throwAndEmitError(
Error(
`Couldn't find root with id "${rootID}": no matching node was found in the Store.`,View on GitHub (pinned to eafeac097b)
Solutions
- Bounds-check before reading: if (index >= 0 && index < store.numElements).
- Re-derive the element from an id (store.getElementByID) instead of a positional index when stability matters.
- Make sure components re-render on store mutation events so indices are recomputed from the current tree.
Example fix
// before
const element = store.getElementAtIndex(index); // warns when index is stale
// after
const element =
index >= 0 && index < store.numElements
? store.getElementAtIndex(index)
: null; Defensive patterns
Strategy: validation
Validate before calling
const element =
index >= 0 && index < store.numElements
? store.getElementAtIndex(index)
: null; Prevention
- Always bounds-check indices against store.numElements before reading.
- Prefer id-based lookups (getElementByID) over positional indices for anything cached across renders.
- Re-render list rows on every store mutation event so indices stay fresh.
When it happens
Trigger: Calling store.getElementAtIndex with an index captured before a store mutation (element unmounted, filters changed) reduced numElements; selection persistence code that replays an old index after the tree changed; virtualization code reading rows from a stale snapshot.
Common situations: Components tab scrolling during rapid updates; owner-tree or filter toggles shrinking the tree while a render is in flight; custom DevTools embeds caching indices across commits.
Related errors
- No element found with id "${id}"
- No suspense found with id "${id}"
- <Element> Could not find element at index ${index}
- Cannot not suspend ID '${suspendedSet[i]}'.
- Could not find instance with id "${id}"
AI-assisted analysis of facebook/react@eafeac097b (2026-08-21).
Data as JSON: /api/errors/4647d2c958910315.
Report an issue: GitHub.