Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: improve `useRefreshOnOpen` hook (#49886)

Gildas Garcia6e8b43d7b441
diff --git a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/useRefreshOnOpen.ts b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/useRefreshOnOpen.ts
index 16394d33fa5..5b02e4ddf81 100644
--- a/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/useRefreshOnOpen.ts
+++ b/apps/studio/components/interfaces/Database/Replication/DestinationPanel/DestinationForm/useRefreshOnOpen.ts
@@ -1,4 +1,4 @@
-import { useCallback } from 'react'
+import { useMemo } from 'react'
// Replication metadata (publication names, publication tables, source tables,
// columns) and similar destination-form option lists follow one rule:
@@ -26,12 +26,11 @@ interface UseRefreshOnOpenProps {
}
export const useRefreshOnOpen = ({ isEnabled = true, refetch }: UseRefreshOnOpenProps) => {
- const handleOpenChange = useCallback(
- (isOpen: boolean) => {
+ return useMemo(() => {
+ const handleOpenChange = (isOpen: boolean) => {
if (isOpen && isEnabled) void refetch()
- },
- [isEnabled, refetch]
- )
+ }
- return { handleOpenChange }
+ return { handleOpenChange }
+ }, [isEnabled, refetch])
}