Skip to content

Commit

Permalink
feat: Link, route.push 상관없이 파라미터 받아오기 완료 (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
yeeZinu committed Jun 1, 2024
1 parent 8b5c3df commit ff80d8e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
7 changes: 1 addition & 6 deletions src/app/(userpage)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
export default function UserLayout({ children }: { children: React.ReactNode }) {
return (
<section>
<div>여기가 레이아웃</div>
{children}
</section>
);
return <section>{children}</section>;
}
3 changes: 2 additions & 1 deletion src/app/(userpage)/mypage/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import cn from "@/utils/classNames";
import styles from "./MyPage.module.scss";

export default function MyPage() {
const userId = "2";
return (
<div className={cn(styles.container)}>
<span>MyPage</span>
<Link href='/otherpage/2'>이동 부탁</Link>
<Link href={`/otherpage/${userId}`}>이동 부탁</Link>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

.container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
7 changes: 4 additions & 3 deletions src/app/(userpage)/otherpage/[userId]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
"use client";

import { useSearchParams } from "next/navigation";
import { useParams } from "next/navigation";
import React from "react";
import cn from "@/utils/classNames";
import styles from "./OtherPage.module.scss";

export default function OtherPage() {
const userId = useSearchParams();
// userId를 받아오는 useParams function
const { userId } = useParams<{ userId: string }>();

return (
<div className={cn(styles.container)}>
<h1> OtherPage test </h1>
<span>{userId}</span>
<span>userId: {userId}</span>
</div>
);
}

0 comments on commit ff80d8e

Please sign in to comment.