Skip to content

Commit

Permalink
fixed linting issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ishtails committed Sep 25, 2024
1 parent 221ef1f commit 8a7bbbc
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ export const StarsBackground: React.FC<StarBackgroundProps> = ({
updateStars();

const resizeObserver = new ResizeObserver(updateStars);
if (canvasRef.current) {
resizeObserver.observe(canvasRef.current);
const currentCanvas = canvasRef.current; // Copy the ref value to a variable
if (currentCanvas) {
resizeObserver.observe(currentCanvas);
}

return () => {
if (canvasRef.current) {
resizeObserver.unobserve(canvasRef.current);
if (currentCanvas) {
resizeObserver.unobserve(currentCanvas);
}
};
}, [starDensity, allStarsTwinkle, twinkleProbability, minTwinkleSpeed, maxTwinkleSpeed, generateStars]);
Expand Down

0 comments on commit 8a7bbbc

Please sign in to comment.