Skip to content

Commit 79fe275

Browse files
committed
Remove state management
1 parent 9f8875f commit 79fe275

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

src/useBreakpoints.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { useState, useLayoutEffect } from 'react';
21
import { useResizeObserverEntry } from './useResizeObserverEntry';
32

43
const boxOptions = {
@@ -45,9 +44,6 @@ const useBreakpoints = ({
4544
}, injectResizeObserverEntry = undefined) => {
4645
const resizeObserverEntry = useResizeObserverEntry(injectResizeObserverEntry);
4746

48-
const [width, setWidth] = useState(undefined);
49-
const [height, setHeight] = useState(undefined);
50-
5147
let entryBox, entryWidth, entryHeight;
5248

5349
if (resizeObserverEntry) {
@@ -76,12 +72,10 @@ const useBreakpoints = ({
7672
}
7773
}
7874

79-
useLayoutEffect(() => {
80-
setWidth(findBreakpoint(widths, entryWidth));
81-
setHeight(findBreakpoint(heights, entryHeight));
82-
}, [widths, entryWidth, heights, entryHeight]);
75+
const widthMatch = findBreakpoint(widths, entryWidth);
76+
const heightMatch = findBreakpoint(heights, entryHeight);
8377

84-
return [width, height];
78+
return [widthMatch, heightMatch];
8579
};
8680

8781
export { useBreakpoints };

0 commit comments

Comments
 (0)