TanStackT
TanStack12mo ago
3 replies
verbal-lime

Change parent layout based on child route matching

Hi, I have a parent layout component and I need to render it a bit differently if a certain child route is active. I've tried to do useLoaderData({ from: "child route" }) but it throws if the child route is not matched.

Is it recommended to un-nest from the parent routes and just render the layout in the child route? If I do that, I can't grab the parent loaded data which means I have to repeat the parent data loading in the child route, it's not a problem, but I just wanted to know if there's a better way. Cheers
Was this page helpful?