fix: Move useMemo above early returns in ReviewTab to fix hooks ordering crash
The allFiles useMemo was declared after two early-return branches. Approving the last phase empties pendingReviewPhases, triggering the early return and causing React to see fewer hooks than the previous render.
This commit is contained in:
@@ -262,6 +262,17 @@ export function ReviewTab({ initiativeId }: ReviewTabProps) {
|
||||
|
||||
const unresolvedCount = comments.filter((c) => !c.resolved).length;
|
||||
|
||||
const activePhaseName =
|
||||
diffQuery.data?.phaseName ??
|
||||
pendingReviewPhases.find((p) => p.id === activePhaseId)?.name ??
|
||||
"Phase";
|
||||
|
||||
// All files from the full branch diff (for sidebar file list)
|
||||
const allFiles = useMemo(() => {
|
||||
if (!diffQuery.data?.rawDiff) return [];
|
||||
return parseUnifiedDiff(diffQuery.data.rawDiff);
|
||||
}, [diffQuery.data?.rawDiff]);
|
||||
|
||||
// Initiative-level review takes priority
|
||||
if (isInitiativePendingReview) {
|
||||
return (
|
||||
@@ -283,17 +294,6 @@ export function ReviewTab({ initiativeId }: ReviewTabProps) {
|
||||
);
|
||||
}
|
||||
|
||||
const activePhaseName =
|
||||
diffQuery.data?.phaseName ??
|
||||
pendingReviewPhases.find((p) => p.id === activePhaseId)?.name ??
|
||||
"Phase";
|
||||
|
||||
// All files from the full branch diff (for sidebar file list)
|
||||
const allFiles = useMemo(() => {
|
||||
if (!diffQuery.data?.rawDiff) return [];
|
||||
return parseUnifiedDiff(diffQuery.data.rawDiff);
|
||||
}, [diffQuery.data?.rawDiff]);
|
||||
|
||||
return (
|
||||
<div className="rounded-lg border border-border bg-card">
|
||||
{/* Header: phase selector + toolbar */}
|
||||
|
||||
Reference in New Issue
Block a user