Removed some unnecessary functions
Brian Vaughn committed
Apr 7, 2019 at 09:58 UTC
df00a9639ea648f0bcd7f62fb545cb403844396f
1 file changed
+10
-15
src/devtools/views/Components/OwnersStack.js
+10
-15
@@ -129,9 +129,7 @@ export default function OwnerStack() {
129
useElementsBarOverflowing(
130
elementsBarRef,
131
elementsTotalWidth,
132
- isElementsBarOverflowing => {
133
- setIsElementsBarOverflowing(isElementsBarOverflowing);
134
- }
132
+ setIsElementsBarOverflowing
133
);
134
135
return (
@@ -163,28 +161,25 @@ function useElementsBarOverflowing(
161
elementsTotalWidth: number,
162
callback: Function
163
) {
166
- const isElementsBarOverflowing = useCallback(() => {
167
- if (elementsBarRef.current !== null) {
168
- const elementsBarWidth = elementsBarRef.current.clientWidth;
169
- return elementsBarWidth <= elementsTotalWidth;
170
- }
171
- return false;
172
- }, [elementsBarRef, elementsTotalWidth]);
173
-
164
useEffect(() => {
165
const handleResize = () => {
176
- callback(isElementsBarOverflowing());
166
+ let isElementsBarOverflowing = false;
167
+ if (elementsBarRef.current !== null) {
168
+ const elementsBarWidth = elementsBarRef.current.clientWidth;
169
+ isElementsBarOverflowing = elementsBarWidth <= elementsTotalWidth;
170
+ }
171
+ callback(isElementsBarOverflowing);
172
};
173
const debounceHandleResize = throttle(handleResize, 100);
174
175
handleResize();
176
+
177
// It's important to listen to the ownerDocument.defaultView to support the browser extension.
178
// Here we use portals to render individual tabs (e.g. Profiler),
179
// and the root document might belong to a different window.
180
const ownerWindow = elementsBarRef.current.ownerDocument.defaultView;
181
ownerWindow.addEventListener('resize', debounceHandleResize);
186
- return () => {
182
+ return () =>
183
ownerWindow.removeEventListener('resize', debounceHandleResize);
188
- };
189
- }, [elementsBarRef, isElementsBarOverflowing, callback]);
184
+ }, [elementsBarRef, elementsTotalWidth, callback]);
185
}