Skip to content

A local-first personal finance app

Fix react/exhaustive-deps in PayeeTable (#6863)

Joel Jeremy Marquez2fb98156f604
diff --git a/packages/desktop-client/src/components/payees/PayeeTable.tsx b/packages/desktop-client/src/components/payees/PayeeTable.tsx
index 32646798b0..9a28ec8a4e 100644
--- a/packages/desktop-client/src/components/payees/PayeeTable.tsx
+++ b/packages/desktop-client/src/components/payees/PayeeTable.tsx
@@ -2,6 +2,7 @@
import {
forwardRef,
useCallback,
+ useEffectEvent,
useLayoutEffect,
useState,
type ComponentProps,
@@ -41,12 +42,15 @@ export const PayeeTable = forwardRef<
const [hovered, setHovered] = useState(null);
const selectedItems = useSelectedItems();
- useLayoutEffect(() => {
+ const onScrollToSelected = useEffectEvent(() => {
const firstSelected = [...selectedItems][0] as string;
if (typeof ref !== 'function') {
ref.current.scrollTo(firstSelected, 'center');
}
- // oxlint-disable-next-line react-hooks/exhaustive-deps
+ });
+
+ useLayoutEffect(() => {
+ onScrollToSelected();
}, []);
const onHover = useCallback(id => {
diff --git a/upcoming-release-notes/6863.md b/upcoming-release-notes/6863.md
new file mode 100644
index 0000000000..341c661176
--- /dev/null
+++ b/upcoming-release-notes/6863.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [joel-jeremy]
+---
+
+Fix react-hooks/exhaustive-deps in in PayeeTable