Skip to content

Commit

Permalink
Update useHashRedirect.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
brody192 committed Dec 19, 2024
1 parent 7594365 commit 9f80490
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/hooks/useHashRedirect.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { useEffect } from "react";
import { useRouter } from "next/router";
import { hashRedirects } from "../../redirects";

export function useHashRedirect() {
const router = useRouter();

useEffect(() => {
const hash = window.location.hash;

Expand All @@ -13,9 +10,7 @@ export function useHashRedirect() {
const redirect = hashRedirects.find(
redirect => redirect.source === hash,
);

if (redirect) router.push(redirect.destination);
}, [router]);

return;
}

if (redirect) window.location.replace(redirect.destination);
}, []);
}

0 comments on commit 9f80490

Please sign in to comment.