admin管理员组文章数量:1355532
I'm building a Next.js application using the App Router and I'm having trouble accessing route parameters from parent components that are higher in the routing hierarchy. My route structure:
app/page.tsx
(Root page)
app/layout.tsx
(Root layout)
app/[category]/page.js
(Category-specific layout)
I need to access the [category]
dynamic parameter from either app/page.tsx
or app/layout.tsx`, which are strictly server components.
For example, if the user navigates to /products/electronics
, I want to be able to access the value electronics
in my root layout or page, but I'm not sure how to do this with server components since these parameters only exist when that segment of the URL is accessed.
本文标签: javascriptHow to access child route parameters from parent routes in Nextjs App RouterStack Overflow
版权声明:本文标题:javascript - How to access child route parameters from parent routes in Next.js App Router? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743990233a2572000.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论