fix: handling invalid user id causing error

This commit is contained in:
Junseo Park 2021-02-22 22:33:41 +09:00
parent 33a235c9f1
commit 52945d03ed

View File

@ -20,7 +20,7 @@ const Advertisement = dynamic(() => import('@components/Advertisement'))
const Tooltip = dynamic(() => import('@components/Tooltip'))
const Users: NextPage<UserProps> = ({ data }) => {
if (!data.id) return <NotFound />
if (!data?.id) return <NotFound />
return (
<Container paddingTop className='py-10'>
<SEO
@ -95,7 +95,7 @@ const Users: NextPage<UserProps> = ({ data }) => {
export const getServerSideProps = async (ctx: Context) => {
const data = await Query.get.user.load(ctx.query.id)
return { props: { data, date: SnowflakeUtil.deconstruct(data.id ?? '0')?.date?.toJSON() } }
return { props: { data, date: SnowflakeUtil.deconstruct(data?.id ?? '0')?.date?.toJSON() } }
}
interface UserProps {