Skip to content

Commit 4e7e828

Browse files
abhizipstackclaude
andcommitted
fix: CreateConnection crash — hasDetailsChanged used before declaration
The useMemo for hasDetailsChanged was declared after the useCallback (handleCreateOrUpdate) that references it in its dependency array. JavaScript's temporal dead zone causes a ReferenceError when the useCallback closure captures the variable before the useMemo initializes it. Moved the useMemo above the useCallback. Introduced by PR #57 (connection name/description edit fix). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f4e9081 commit 4e7e828

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

frontend/src/base/components/environment/CreateConnection.jsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,14 @@ const CreateConnection = ({
125125
getConnectionFields();
126126
}, [getConnectionFields]);
127127

128+
const hasDetailsChanged = useMemo(() => {
129+
if (!connectionId || !originalDbSelectionInfo) return false;
130+
return (
131+
formName !== originalDbSelectionInfo.name ||
132+
formDescription !== originalDbSelectionInfo.description
133+
);
134+
}, [connectionId, formName, formDescription, originalDbSelectionInfo]);
135+
128136
const handleCreateOrUpdate = useCallback(async () => {
129137
setIsCreateOrUpdateLoading(true);
130138
try {
@@ -407,15 +415,6 @@ const CreateConnection = ({
407415
[dbSelectionInfo.datasource_name, selectedOrgId, csrfToken, connType]
408416
);
409417

410-
// Detect if connection name or description changed (metadata-only changes)
411-
const hasDetailsChanged = useMemo(() => {
412-
if (!connectionId || !originalDbSelectionInfo) return false;
413-
return (
414-
formName !== originalDbSelectionInfo.name ||
415-
formDescription !== originalDbSelectionInfo.description
416-
);
417-
}, [connectionId, formName, formDescription, originalDbSelectionInfo]);
418-
419418
const mappedDataSources = useMemo(
420419
() =>
421420
dataSources.map((dSource) => ({

0 commit comments

Comments
 (0)