중첩 레이아웃은 root layout 안에 세그먼트 layout을 다시 끼운다
dashboard/layout.tsx를 만들면 /dashboard 아래 페이지는 root layout과 dashboard layout을 함께 통과한다.
| 경로 | 적용되는 layout | children 자리에 들어가는 것 | 화면 결과 |
|---|---|---|---|
| / | src/app/layout.tsx | src/app/page.tsx | 헤더, 홈 화면, 푸터 |
| /about | src/app/layout.tsx | src/app/about/page.tsx | 헤더, 소개 화면, 푸터 |
| /dashboard | root + dashboard/layout.tsx | dashboard/page.tsx | 헤더, 사이드바, 대시보드 홈, 푸터 |
| /dashboard/settings | root + dashboard/layout.tsx | settings/page.tsx | 헤더, 사이드바, 설정 화면, 푸터 |
| layout 위치 변경 | 상위 폴더로 올리면 범위 확대 | 더 많은 page가 영향 받음 | 의도하지 않은 공유 UI를 주의 |