Skip to content

Commit

Permalink
feat: navigator hook 구현 및 기본 구조 구현 (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
yeeZinu committed May 31, 2024
1 parent 06b575c commit d0b400d
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/app/(userpage)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default function UserLayout({ children }: { children: React.ReactNode }) {
return (
<section>
<div>여기가 레이아웃</div>
{children}
</section>
);
}
5 changes: 5 additions & 0 deletions src/app/(userpage)/mypage/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from "react";

export default function MyPage() {
return <div>MyPage</div>;
}
5 changes: 5 additions & 0 deletions src/app/(userpage)/otherpage/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from "react";

export default function OtherPage() {
return <div>OtherPage</div>;
}
5 changes: 5 additions & 0 deletions src/app/(userpage)/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from "react";

export default function page() {
return <div>여기 진짜 페이지임 ㅇㅇ</div>;
}
17 changes: 17 additions & 0 deletions src/hooks/useNavigateToUserPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { useRouter } from "next/router";

const useNavigateToUserPage = (currentUserId: string) => {
const router = useRouter();

const navigateToUserPage = (userId: string) => {
if (userId === currentUserId) {
router.push("/userpage/mypage");
} else {
router.push(`/userpage/otherpage?userId=${userId}`);
}
};

return navigateToUserPage;
};

export default useNavigateToUserPage;

0 comments on commit d0b400d

Please sign in to comment.