Skip to content

Commit

Permalink
✨ feat: window history 없는 경우 back button click시 home으로 routing
Browse files Browse the repository at this point in the history
  • Loading branch information
chaaerim authored and minsgy committed Feb 25, 2024
1 parent 1fb559c commit daaa206
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/common/components/BackHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@ import { ICON_URL, SSRSuspense } from '@/common';

export const BackHeader = () => {
const router = useRouter();

const onClick = () => {
if (typeof window !== 'undefined' && window.history.length > 1) {
router.back();
} else {
router.push('/');
}
};
return (
<SSRSuspense
fallback={<div className="h-54px bg-gray-120">로딩중입니다..</div>}
>
<nav className="sticky left-0 right-0 top-0 z-50 h-54px bg-gray-120">
<div className="flex h-full w-full items-center justify-between">
<button type="button" onClick={() => router.back()}>
<button type="button" onClick={onClick}>
<Image
className="h-auto w-24px"
src={ICON_URL.CHEVRON_LEFT_BIG}
Expand Down

0 comments on commit daaa206

Please sign in to comment.