fix: hooks order violation in DeadlineResolveDialog causing crash
useMemo was called after early return (when deadline=null), violating React Rules of Hooks. Moved all hooks before the conditional return. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -30,9 +30,7 @@ export function DeadlineResolveDialog({ open, deadline, onOpenChange, onResolve
|
||||
const [resolution, setResolution] = useState<DeadlineResolution>('completed');
|
||||
const [note, setNote] = useState('');
|
||||
|
||||
if (!deadline) return null;
|
||||
|
||||
const def = getDeadlineType(deadline.typeId);
|
||||
const def = deadline ? getDeadlineType(deadline.typeId) : undefined;
|
||||
|
||||
// "intrerupt" option only for avize deadlines that have a chain (interruption mechanism)
|
||||
const filteredOptions = useMemo(() => {
|
||||
@@ -45,6 +43,8 @@ export function DeadlineResolveDialog({ open, deadline, onOpenChange, onResolve
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [def?.chainNextTypeId, def?.category]);
|
||||
|
||||
if (!deadline) return null;
|
||||
|
||||
// Chain fires on completed, aprobat-tacit, or intrerupt (for avize interruption)
|
||||
const hasChain = def?.chainNextTypeId && (
|
||||
resolution === 'completed' || resolution === 'aprobat-tacit' || resolution === 'intrerupt'
|
||||
|
||||
Reference in New Issue
Block a user