File tree Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ const useDimensions = <T extends HTMLElement | null>({
107107 // eslint-disable-next-line compat/compat
108108 observerRef . current = new ( polyfill || window . ResizeObserver ) (
109109 ( [ entry ] : any ) => {
110- window . requestAnimationFrame ( ( ) => {
110+ rafId = window . requestAnimationFrame ( ( ) => {
111111 const { contentBoxSize, borderBoxSize, contentRect } = entry ;
112112
113113 let boxSize = contentBoxSize ;
@@ -166,25 +166,21 @@ const useDimensions = <T extends HTMLElement | null>({
166166 breakpoints &&
167167 updateOnBreakpointChange
168168 ) {
169- rafId = requestAnimationFrame ( ( ) => {
170- setState ( ( prev ) =>
171- prev . currentBreakpoint !== next . currentBreakpoint ? next : prev
172- ) ;
173- } ) ;
169+ setState ( ( prev ) =>
170+ prev . currentBreakpoint !== next . currentBreakpoint ? next : prev
171+ ) ;
174172 return ;
175173 }
176174
177- rafId = requestAnimationFrame ( ( ) => {
178- setState ( next ) ;
179- } ) ;
175+ setState ( next ) ;
180176 } )
181177 } ) ;
182178
183179 observe ( ) ;
184180
185181 return ( ) => {
186182 unobserve ( ) ;
187- if ( rafId ) cancelAnimationFrame ( rafId ) ;
183+ if ( rafId ) window . cancelAnimationFrame ( rafId ) ;
188184 } ;
189185 // eslint-disable-next-line react-hooks/exhaustive-deps
190186 } , [
You can’t perform that action at this time.
0 commit comments