Created
January 4, 2024 00:22
-
-
Save sametcn99/dacba6034067d275cfaa74738d078d8d to your computer and use it in GitHub Desktop.
This code appears to be a React component designed for redirection in a Next.js application. Let's break down the main components:
This file contains hidden or 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
| "use client"; | |
| import { useRouter } from "next/navigation"; | |
| import { useEffect } from "react"; | |
| import Loading from "@/app/loading"; | |
| type RedirectProps = { | |
| searchParams: { url: string }; | |
| }; | |
| export default function Redirect({ searchParams }: RedirectProps) { | |
| const router = useRouter(); | |
| useEffect(() => { | |
| const redirectTimeout = setTimeout(() => { | |
| router.push(searchParams.url); | |
| }, 1000); | |
| return () => clearTimeout(redirectTimeout); | |
| }, [router, searchParams.url]); | |
| return ( | |
| <section className="flex h-screen w-full flex-col items-center justify-center gap-4 text-2xl font-bold"> | |
| <h1>Redirecting...</h1> | |
| </section> | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment