if i made the layout.tsx that warps the entire app "use client" to use react hooks
Answered
Himalayan posted this in #help-forum
HimalayanOP
if i made the layout.tsx that warps the entire app "use client" to use react hooks, will it affect the entire app? cuz i need to get the pathname, i dont want to show the navbar and the footer in "/login" or "sign-up" even if the "layout.tsx" that has these components warps them
Answered by Rafael Almeida
yeah adding
'use client' is pretty bad in the layout file. its better to use route groups for what you are trying to do: https://nextjs.org/docs/app/building-your-application/routing/route-groups11 Replies
HimalayanOP
i'm using headers but the problem with that is the value not being updated, so i need to use hooks ig
is there any better solutions?
yeah adding
'use client' is pretty bad in the layout file. its better to use route groups for what you are trying to do: https://nextjs.org/docs/app/building-your-application/routing/route-groupsAnswer
@Himalayan if i made the layout.tsx that warps the entire app "use client" to use react hooks, will it affect the entire app? cuz i need to get the pathname, i dont want to show the navbar and the footer in "/login" or "sign-up" even if the "layout.tsx" that has these components warps them
Why don't you just create multiple layouts ?
@Rafael Almeida yeah adding `'use client'` is pretty bad in the layout file. its better to use route groups for what you are trying to do: <https://nextjs.org/docs/app/building-your-application/routing/route-groups>
HimalayanOP
will the nested group layout overwrite the main layout?
@Youssef Why don't you just create multiple layouts ?
HimalayanOP
cant in this case
it will be the same
no, the layouts are composed on top of each other. what you need to do is to create multiple root layouts: https://nextjs.org/docs/app/building-your-application/routing/route-groups#creating-multiple-root-layouts
so you would have a group for
/loginand /sign-up with a layout without the navbar and footer and the rest of the pages go in the other groupHimalayanOP
got it
ty!