chore: made some changes at redirect

This commit is contained in:
wonderlandpark 2021-03-25 15:53:38 +09:00
parent 0ebb78b57c
commit 3f57eac291

View File

@ -1,3 +1,4 @@
import { ReactNode } from 'react'
import dynamic from 'next/dynamic'
import { useRouter } from 'next/router'
@ -5,10 +6,13 @@ import { redirectTo } from '@utils/Tools'
const Container = dynamic(() => import('@components/Container'))
const Redirect = ({ to }:RedirectProps):JSX.Element => {
const Redirect = ({ to, children }:RedirectProps):JSX.Element => {
const router = useRouter()
if(!to) throw new Error('No Link')
redirectTo(router, to)
if(children) return <>
{children}
</>
return <Container paddingTop>
<div>
<a href={to} className='text-blue-400'> .</a>
@ -18,6 +22,7 @@ const Redirect = ({ to }:RedirectProps):JSX.Element => {
interface RedirectProps {
to: string
children?: ReactNode
}
export default Redirect