mirror of
https://github.com/davidkaya/aryx.git
synced 2026-08-09 05:08:44 +02:00
fix: move useCallback before early return to fix hooks ordering
The jumpToMessage useCallback was placed after a conditional return, violating React's Rules of Hooks and crashing the app on render. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -173,6 +173,15 @@ export default function App() {
|
|||||||
[workspace?.projects],
|
[workspace?.projects],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const jumpToMessage = useCallback((messageId: string) => {
|
||||||
|
const element = document.querySelector(`[data-message-id="${CSS.escape(messageId)}"]`);
|
||||||
|
if (element) {
|
||||||
|
element.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||||
|
element.classList.add('ring-1', 'ring-indigo-500/40', 'rounded-lg');
|
||||||
|
setTimeout(() => element.classList.remove('ring-1', 'ring-indigo-500/40', 'rounded-lg'), 1500);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
// Loading state
|
// Loading state
|
||||||
if (!workspace) {
|
if (!workspace) {
|
||||||
return (
|
return (
|
||||||
@@ -192,15 +201,6 @@ export default function App() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const jumpToMessage = useCallback((messageId: string) => {
|
|
||||||
const element = document.querySelector(`[data-message-id="${CSS.escape(messageId)}"]`);
|
|
||||||
if (element) {
|
|
||||||
element.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
||||||
element.classList.add('ring-1', 'ring-indigo-500/40', 'rounded-lg');
|
|
||||||
setTimeout(() => element.classList.remove('ring-1', 'ring-indigo-500/40', 'rounded-lg'), 1500);
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
// Determine main content
|
// Determine main content
|
||||||
let content: React.ReactNode;
|
let content: React.ReactNode;
|
||||||
let detailPanel: React.ReactNode | undefined;
|
let detailPanel: React.ReactNode | undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user