Skip to content

Commit d116ffe

Browse files
nolancacheuxclaude
andcommitted
fix: move useMemo before early return for hooks rules
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b75970c commit d116ffe

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/components/3d/NetworkVisualization.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,7 @@ function GridFloor() {
322322
function BackgroundStars() {
323323
const theme = useNetworkStore(state => state.ui.theme);
324324

325-
if (theme !== 'dark') return null;
326-
327-
// Use useMemo to generate consistent star positions
325+
// Use useMemo to generate consistent star positions (must be called before any early returns)
328326
const stars = useMemo(() => {
329327
return Array.from({ length: 100 }).map((_, i) => ({
330328
position: [
@@ -337,6 +335,8 @@ function BackgroundStars() {
337335
}));
338336
}, []);
339337

338+
if (theme !== 'dark') return null;
339+
340340
return (
341341
<>
342342
{stars.map((star, i) => (

0 commit comments

Comments
 (0)