Skip to content

Commit 97d6678

Browse files
Copilothotlong
andcommitted
fix: remove useMemo after early returns to fix React error #310
The useMemo hook was placed after conditional early returns in RecordDetailView, violating React's Rules of Hooks and causing "Rendered fewer hooks than expected" (React error #310). Replaced with an IIFE to keep the same Set-based dedup logic without hooks. Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent f417212 commit 97d6678

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

apps/console/src/components/RecordDetailView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ export function RecordDetailView({ dataSource, objects, onEdit }: RecordDetailVi
387387
];
388388

389389
// Filter actions for record_header location and deduplicate by name
390-
const recordHeaderActions = useMemo(() => {
390+
const recordHeaderActions = (() => {
391391
const seen = new Set<string>();
392392
return (objectDef.actions || []).filter((a: any) => {
393393
if (!a.locations?.includes('record_header')) return false;
@@ -396,7 +396,7 @@ export function RecordDetailView({ dataSource, objects, onEdit }: RecordDetailVi
396396
seen.add(a.name);
397397
return true;
398398
});
399-
}, [objectDef.actions]);
399+
})();
400400

401401
// Build highlightFields: prefer explicit config, fallback to auto-detect key fields
402402
const explicitHighlight: HighlightField[] | undefined = objectDef.views?.detail?.highlightFields;

0 commit comments

Comments
 (0)