Skip to content

Commit

Permalink
Revert "chore: meteors use useMemo"
Browse files Browse the repository at this point in the history
This reverts commit 9d0ff0d.
  • Loading branch information
Debbl committed Jan 11, 2025
1 parent 9d0ff0d commit 45c5074
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/components/magicui/Meteors.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
"use client";

import { useMemo } from "react";
import { useEffect, useState } from "react";
import { cn } from "~/lib/utils";

interface MeteorsProps {
number?: number;
}
export const Meteors = ({ number = 20 }: MeteorsProps) => {
const meteorStyles = useMemo(
() =>
Array.from({ length: number }).map(() => ({
top: -5,
left: `${Math.floor(Math.random() * window.innerWidth)}px`,
animationDelay: `${Math.random() * 1 + 0.2}s`,
animationDuration: `${Math.floor(Math.random() * 8 + 2)}s`,
})),
[number],
const [meteorStyles, setMeteorStyles] = useState<Array<React.CSSProperties>>(
[],
);

useEffect(() => {
const styles = Array.from({ length: number }).map(() => ({
top: -5,
left: `${Math.floor(Math.random() * window.innerWidth)}px`,
animationDelay: `${Math.random() * 1 + 0.2}s`,
animationDuration: `${Math.floor(Math.random() * 8 + 2)}s`,
}));
setMeteorStyles(styles);
}, [number]);

return (
<>
{meteorStyles.map((style, idx) => (
{[...meteorStyles].map((style, idx) => (
// Meteor Head
<span
key={idx}

Check warning on line 29 in src/components/magicui/Meteors.tsx

View workflow job for this annotation

GitHub Actions / lint

Do not use Array index as 'key'
Expand Down

0 comments on commit 45c5074

Please sign in to comment.