Don't re-measure owners stack sizes unnecessarily
Brian Vaughn committed
Apr 8, 2019 at 12:05 UTC
e43cfa02396fa5fb00c2d23378811c1d0e54bb6b
1 file changed
+5
-2
src/devtools/views/Components/OwnersStack.js
+5
-2
@@ -28,7 +28,10 @@ export default function OwnerStack() {
28
const isOverflowing = useIsOverflowing(elementsBarRef, elementsTotalWidth);
29
30
useLayoutEffect(() => {
31
- if (elementsBarRef.current === null) {
31
+ // If we're already overflowing, then we don't need to re-measure items.
32
+ // That's because once the owners stack is open, it can only get larger (by driling in).
33
+ // A totally new stack can only be reached by exiting this mode and re-entering it.
34
+ if (elementsBarRef.current === null || isOverflowing) {
35
return () => {};
36
}
37
@@ -44,7 +47,7 @@ export default function OwnerStack() {
47
}
48
49
setElementsTotalWidth(elementsTotalWidth);
47
- }, [elementsBarRef, ownerStack.length]);
50
+ }, [elementsBarRef, isOverflowing, ownerStack.length]);
51
52
return (
53
<div className={styles.OwnerStack}>