-
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.
- Loading branch information
1 parent
c20cd46
commit 94c0f2d
Showing
1 changed file
with
5 additions
and
4 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 |
---|---|---|
|
@@ -36,14 +36,13 @@ export default function Heading() { | |
const typedRef = useRef<HTMLSpanElement>(null); | ||
|
||
useEffect(() => { | ||
// Dynamic script loader for Typed.js | ||
const script = document.createElement("script"); | ||
script.src = "https://cdn.jsdelivr.net/npm/[email protected]"; | ||
script.async = true; | ||
|
||
script.onload = () => { | ||
if (typeof window.Typed !== "undefined" && typedRef.current) { | ||
const typed = new window.Typed(typedRef.current, { | ||
if (typedRef.current && typeof window.Typed !== "undefined") { | ||
const typed = new (window as any).Typed(typedRef.current, { | ||
strings: [ | ||
"Make, Build, Create & Learn.", | ||
"It’s GunnHacks 11.0.", | ||
|
@@ -55,13 +54,15 @@ export default function Heading() { | |
loop: true, | ||
}); | ||
|
||
return () => typed.destroy(); // Cleanup on unmount | ||
// Cleanup Typed instance on component unmount | ||
return () => typed.destroy(); | ||
} | ||
}; | ||
|
||
document.body.appendChild(script); | ||
|
||
return () => { | ||
// Clean up script | ||
document.body.removeChild(script); | ||
}; | ||
}, []); | ||
|