@samitouri / QOS-React-2 / commits / dc08e80037

Cache list rows by Element ID rather than index

This is important since we are caching element sizes by DOM (in a WeakMap). Toggling (as well as insertion/deletion) might otherwise break this in some cases.

Brian Vaughn committed Jun 2, 2019 at 20:10 UTC dc08e80037cfc05e08b1e4ad82210531afb6a227
1 file changed +6
src/devtools/views/Components/Tree.js
+6
@@ -274,6 +274,11 @@ export default function Tree(props: Props) {
274 ]
275 );
276
277 + const itemKey = useCallback(
278 + (index: number) => store.getElementIDAtIndex(index),
279 + [store]
280 + );
281 +
282 return (
283 <TreeFocusedContext.Provider value={treeFocused}>
284 <ComponentFiltersModalContextController>
@@ -306,6 +311,7 @@ export default function Tree(props: Props) {
311 innerElementType={InnerElementType}
312 itemCount={numElements}
313 itemData={itemData}
314 + itemKey={itemKey}
315 itemSize={lineHeight}
316 ref={listRef}
317 width={width}