#Replace Parent Layout

110 messages Β· Page 1 of 1 (latest)

mild lodge
#

Hi!

I understand that the RootLayout wraps all other layouts in our child routes, but in v12 I had the possibility to always define my own getLayout and pass some props like withContainer (which is defined in my Layout component).

Is there any chance to replace the parent layout inside my child route?

smoky ferry
#

Have you looked into route groups?

mild lodge
#

oh wait..

smoky ferry
#

that's exactly what that link is for πŸ˜›

#

() does not affect path so they get merged

mild lodge
#

I see

mild lodge
#

if I remove the top level layout and put it in a folder called (root)/layout.tsx where basically every route share the same layout

#

and move my rewrite route to a separate folder like (profile)/profile/[username] its complaining like that my [username] is not a React.component

#

even when there is a page.tsx which seems working outside the route group

#

wtf after restarting the next dev it seems to work now

#

looks like next dev can't really handle folder movement or deletion

smoky ferry
#

ahhh, I have had that fix a few things over the last few days. πŸ˜›

#

I haven't tried without deleting .next though. I always delete that first. I'll have to try only restarting next time.

mild lodge
#

so if I understand correctly they also changed the behaviour of error

#

like before I had a 404.tsx because error.tsx was kinda buggy before (always tried to reload / fetch smth)

smoky ferry
#

I've only been using React/Next.js for a couple of days so not quite sure on the changes.

mild lodge
#

notFound()

#

huh

#

these changes are driving me crazy

#

ngl

smoky ferry
#

haha, well you don't have to use them πŸ˜›

#

I'm starting a new app so it has been pretty painless

#

but I can see migrating an existing project being a pain

#

13 happened to come out pretty much the day I started my project

mild lodge
#

you are really lucky

#

ngl

smoky ferry
#

if I had an existing code base that was chonky I wouldn't even try to migrate

mild lodge
#

now I'm kinda confused. I added the not-found.tsx into my top level and I still get the basic 404 from nextjs

#

πŸ’€

smoky ferry
#

especially at this stage if it's something in use

#

maybe a restart of dev?

mild lodge
#

did that multiple times now

#

πŸ’€

smoky ferry
#

have you tried in your route group?

mild lodge
#

yep

#

I want a global 404 page

#

not a nested one

#

πŸ’€

smoky ferry
#

yeah, looks like one in /app should be fine

mild lodge
#

guess not-found will be only visible

#

if you use the notFound() function

smoky ferry
#

does whatever you're using call notFound() to make it trigger?

mild lodge
#

but what about if the user enters a invalid url?

smoky ferry
#

404 would not apply anyways

#

oh, wait

mild lodge
#

cuz the error.tsx will not be visible

smoky ferry
#

ignore what I said while I reprocess

mild lodge
#

haha

#

hope they gonna implement rewrites into turbo asap

smoky ferry
#

yeah, I can't seem to trigger the 404 either, hrmm

smoky ferry
#

looks like it compiles too based off of the logs

tall nacelle
#

Super curious why you are switching to the app folder today if you find it to be such hassle.

mild lodge
tall nacelle
#

why though

mild lodge
#

I love these changes ngl but it’s kinda hard to migrate a large existing project

tall nacelle
#

that is what im curious about

#

why would someone be forced to use the app dir?

mild lodge
#

idk why

#

guess they want a new structure

tall nacelle
#

Ok, well that is a shame.

mild lodge
#

πŸ’€πŸ’€πŸ’€

tall nacelle
#

Stupid move

#

Hopefully we can help you get it going mostly

#

and hopefully they dont have unreasonable expectations on what an migration like this looks like

mild lodge
tall nacelle
#

and how long it can take

mild lodge
#

I got the most things done today

#

just missing the custom error page & the API requests

tall nacelle
#

api requests will need to stay in pages

#

or wait responses if you have any

#

the requests you are right

mild lodge
#

actually we are not using the api routes from next

tall nacelle
#

will need to run those in server compnmets

#

ok that is good

mild lodge
#

but I like this new layout thing. especially that my data will be kept in route changes

tall nacelle
#

The only thing I've run into that has been a stopper for me, is the inability to change the response from server components.

#

I have gotten around a bit of it by using middleware

tall nacelle
#

For example had to move my cookies setting to middleware

mild lodge
#

πŸ’―πŸ’―πŸ’―πŸ˜­

#

actually wasn’t there a forum post which provided a good example to pass the data from a server component to a child

#

πŸ€”

tall nacelle
#

I don't have an issue with that. It is really just response mutation

mild lodge
#

the most hard thing for me was using like use client in every page

#

cuz my tailwind components are forcing me to do that

tall nacelle
#

Hehe. Your company asked you to switch to the app folder, maybe for server components, yet your app contains very few server components... big surprise!

#

Our decisions of the past are going to have a major impact on the ease at which we migrate to more client/server hybrid apps like this

#

Is it tailwind UI?

mild lodge
#

I guess it’s not a issue of tailwind but of headless ui

tall nacelle
#

yes

#

definitely, the react package from UI would depend on headless, and headless would depend on react hooks.

mild lodge
#

idk if headless is gonna change that in future

#

but I don’t think so

tall nacelle
#

No don't expect that.

#

you'll have to slice and dice your UI to push client components to the leaves