|
1 | | -import { useState, useLayoutEffect } from 'react'; |
2 | 1 | import { useResizeObserverEntry } from './useResizeObserverEntry'; |
3 | 2 |
|
4 | 3 | const boxOptions = { |
@@ -45,9 +44,6 @@ const useBreakpoints = ({ |
45 | 44 | }, injectResizeObserverEntry = undefined) => { |
46 | 45 | const resizeObserverEntry = useResizeObserverEntry(injectResizeObserverEntry); |
47 | 46 |
|
48 | | - const [width, setWidth] = useState(undefined); |
49 | | - const [height, setHeight] = useState(undefined); |
50 | | - |
51 | 47 | let entryBox, entryWidth, entryHeight; |
52 | 48 |
|
53 | 49 | if (resizeObserverEntry) { |
@@ -76,12 +72,10 @@ const useBreakpoints = ({ |
76 | 72 | } |
77 | 73 | } |
78 | 74 |
|
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); |
83 | 77 |
|
84 | | - return [width, height]; |
| 78 | + return [widthMatch, heightMatch]; |
85 | 79 | }; |
86 | 80 |
|
87 | 81 | export { useBreakpoints }; |
0 commit comments