Browse Source

fix(js): Correct eslint hook rule in useScrollToTop (#34479)

Evan Purkhiser 2 years ago
parent
commit
5cc30a9d8d

+ 1 - 1
static/app/utils/useScrollToTop.tsx

@@ -25,7 +25,7 @@ function useScrollToTop({location, disable}: Options) {
     }
 
     window.scrollTo(0, 0);
-  }, [location]);
+  }, [location, disable]);
 }
 
 export default useScrollToTop;

+ 5 - 5
static/app/views/settings/components/settingsWrapper.tsx

@@ -8,12 +8,12 @@ type Props = {
   location: Location;
 };
 
+function scrollDisable(newLocation: Location, prevLocation: Location) {
+  return newLocation.pathname === prevLocation.pathname;
+}
+
 function SettingsWrapper({location, children}: Props) {
-  useScrollToTop({
-    location,
-    disable: (newLocation, prevLocation) =>
-      newLocation.pathname === prevLocation.pathname,
-  });
+  useScrollToTop({location, disable: scrollDisable});
 
   return <StyledSettingsWrapper>{children}</StyledSettingsWrapper>;
 }