-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ (CursorAnimation.js): Add ErrorBoundary component to catch errors a…
…nd improve error handling in AnimatedPointer component ♻️ (NavLinks.jsx): Remove commented out code for status link in NavLinks component ♻️ (NavLinks.scss): Adjust padding in .navBar li to improve spacing in navigation bar
- Loading branch information
Showing
3 changed files
with
53 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,56 @@ | ||
import React from "react"; | ||
import React, { useEffect, useState } from "react"; | ||
import AnimatedCursor from "react-animated-cursor"; | ||
|
||
// ErrorBoundary component to catch errors | ||
class ErrorBoundary extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { hasError: false }; | ||
} | ||
|
||
static getDerivedStateFromError() { | ||
// Update state so the next render will show the fallback UI | ||
return { hasError: true }; | ||
} | ||
|
||
componentDidCatch(error, info) { | ||
// Log the error to an error reporting service if needed | ||
console.error("Error caught in ErrorBoundary:", error, info); | ||
} | ||
|
||
render() { | ||
if (this.state.hasError) { | ||
// You can render any fallback UI | ||
return <div>Error loading cursor</div>; | ||
} | ||
|
||
return this.props.children; | ||
} | ||
} | ||
|
||
export default function AnimatedPointer() { | ||
const [isClient, setIsClient] = useState(false); | ||
|
||
// Ensure the component only renders on the client side (not SSR) | ||
useEffect(() => { | ||
if (typeof window !== "undefined") { | ||
setIsClient(true); | ||
} | ||
}, []); | ||
|
||
// Only render AnimatedCursor if on the client side | ||
return ( | ||
<div className="App"> | ||
<AnimatedCursor | ||
innerSize={8} | ||
outerSize={22} | ||
color="193, 11, 111" | ||
outerAlpha={0.5} | ||
innerScale={0.2} | ||
outerScale={2} | ||
/> | ||
</div> | ||
isClient && ( | ||
<ErrorBoundary> | ||
<AnimatedCursor | ||
innerSize={8} | ||
outerSize={22} | ||
color="193, 11, 111" | ||
outerAlpha={0.5} | ||
innerScale={0.2} | ||
outerScale={2} | ||
/> | ||
</ErrorBoundary> | ||
) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
} | ||
|
||
.navBar li { | ||
padding: 0.2rem 1.5rem; | ||
padding: 0.2rem 0.6rem; | ||
} | ||
|
||
.active { | ||
|