#weird behavior when using multiple layouts

129 messages · Page 1 of 1 (latest)

bitter dock
#

I have 2 groups (group1) and (group2) with different layouts.tsx files returning <> header, div with {children}</>

I also have a RootLayout in the app folder.

this all works fine when navigating to lages in group1 or group2, but I also have other pages that are just normally in folders within app directly, so: app/routename/page.tsx
When navigating to these pages, there is only raw html, and Im seeing no hydration errors or anything...

tldr:
I have:

  • app/(group1)/layout.tsx
  • app/(group1)/pagename1/page.tsx
  • app/(group2)/layout.tsx
  • app/(group12/pagename2/page.tsx
  • app/pagename3/page.tsx
  • app/layout.tsx

pagename1 and pagename 2 work fine, pagename3 displays raw html.

Am I doing something wrong? (Using tailwindcss btw)

simple shoreBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

young bone
#

how is the code of the root layout /app/layout.tsx ?

covert willow
#

I suspect this has to do with duplicate named or close named groups or routes because that is what happened to me

bitter dock
# young bone how is the code of the root layout `/app/layout.tsx` ?
export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  return (
    <html lang="en" data-theme="dark">
      <body
        className={
          inter.className
        }
      >
        <header>
          <div className="fixed top-0 z-20 w-full">
            <div className="border-sold border-b-[1px] border-b-gray-600 border-opacity-100">
              <Navbar></Navbar>
            </div>
          </div>
        </header>
        <div
          className="pt-[70px] bg-ext_background text-white "
          style={{ minHeight: 'calc(100vh - 0px)' }}
        >
          {children}
        </div>
      </body>
    </html>
  );
}```
bitter dock
#

interestingly also, if I go to localhost/pagename3v directly after starting the server, it all looks fine with tailwindcss styling

#

I can then also go to any of my other pages which are not in a group. only once I navigate to a page that is in a group, if I then go back to one that isnt in a group, its html only.

covert willow
#

can you show us your tailwind config?

bitter dock
#

its mostly default

#
import type { Config } from 'tailwindcss';

const config: Config = {
  // prefix: "tw-",
  content: [
    './pages/**/*.{js,ts,jsx,tsx,mdx}',
    './components/**/*.{js,ts,jsx,tsx,mdx}',
    './app/**/*.{js,ts,jsx,tsx,mdx}',
    './node_modules/preline/dist/*.js',
  ],
  theme: {
    /* colors: {
      navbar: '#6E6B7A',
    }, */
    extend: {
      colors: {
        ext_streamer: '#8B77D5',
        ext_clipper: '#C2A520',
        ext_navbar: '#6E6B7A',
        ext_background: '#111111',
        ext_primary: '#333333',
        ext_accent: '#8F86B6',
        ext_dark_blue: '#2F01EB',
        ext_card_top: '#7D7A89',
        ext_card_bottom: '#6E6B7A',
      },
      backgroundImage: {
        'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
        'gradient-conic':
          'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))',
      },
      /* fontFamily: {
        'b-font': ['Arial', 'sans-serif'],
      }, */
    },
  },
  plugins: [
    require('daisyui'),
    require('tailwind-scrollbar')({ nocompatible: true }),
    require('@tailwindcss/forms'),
  ],
  daisyui: {
    themes: ['light', 'dark', 'cupcake', 'winter', 'dracula'],
    darkTheme: 'dark', // name of one of the included themes for dark mode
    base: true, // applies background color and foreground color for root element by default
    styled: true, // include daisyUI colors and design decisions for all components
    utils: true, // adds responsive and modifier utility classes
    prefix: '', // prefix for daisyUI classnames (components, modifiers and responsive class names. Not colors)
    logs: true, // Shows info about daisyUI version and used config in the console when building your CSS
    themeRoot: ':root', // The element that receives theme color CSS variables
  },
};
export default config;
covert willow
#

one moment while I look at it

#

you're not using src are you?

bitter dock
#

no

#

also I just realized that the issue is not the case for one of my pages

covert willow
#

Is this a tailwind.config.ts or tailwind.config.ts?

bitter dock
#

its tailwind.config.ts

covert willow
#

and why is node_modules included?

bitter dock
#

not sure

#

i dont think I put that there

covert willow
#

Hmm that is odd, unless you're using a theme library link ant design you shouldn't need that

#

oh you're using daisyui

bitter dock
#

I have a page named bounties and the issue never happens there, but since that page is also not in a group just like my signup and login pages, I can navigate between those 3 without the issue happening

#

BUT

#

when I go to a page from a group and then back to the signin or login page the issue happens

#

BUT

covert willow
#

When did this start happening

bitter dock
#

not for the bounties page

#

it happened when I added the groups

#

with seperate layouts

covert willow
#

Ok and you're using the app router exclusively right, no page router pages?

bitter dock
#

yeah

covert willow
#

Do you have a default layout at all?

bitter dock
#

yes

#

thats the rootlayout I posed

covert willow
#

And that isn't being applied of course with these problem pages right?

bitter dock
#

no it is

#

but

#

no styling

#

only raw html

covert willow
#

Ok is the rendered page showing a css stylesheet or a console error?

bitter dock
#

no error

#

stylesheet in sources?

covert willow
#

can I see a layout that isn't being shown as well as the source code for the page itself?

#

or in the head

bitter dock
#

the layout does work just no styling

#

1 sec

covert willow
#

sorry i just meant the parent layout

bitter dock
#

the default root layout in my app folder

#

I already posted

covert willow
#

Ok that's the root layout right?

bitter dock
#

yeah

#

the pages for signup and login are just long forms rly

covert willow
#

could be anything, mind sharing it hastebin if its too long for here?

bitter dock
#

thats app/login/page.tsx

covert willow
#

looking at it now.

#

Wait there is no group on this

#

where is the group in the directory path?

#

that's what I am looking for

bitter dock
#

tldr:
I have:
app/(group1)/layout.tsx
app/(group1)/pagename1/page.tsx
app/(group2)/layout.tsx
app/(group12/pagename2/page.tsx
app/pagename3/page.tsx
app/layout.tsx

#

the group pages which have seperate layouts, they work fine

covert willow
#

this is your problem

#

remove that

young bone
#

are you navigating with classic a tag ?

bitter dock
bitter dock
bitter dock
covert willow
#

ok

#

Show me a problem page, is this one of them?

young bone
#

I meant this

 <a
    href="./signup"
    className="font-semibold leading-6 text-indigo-400 hover:text-indigo-500"
  >
              Create Account
  </a>
bitter dock
#

yes, this is one of the pages that if I go there immediately after starting server its fine, but when I then go to a page that is in a (group) and back there is only raw html

bitter dock
bitter dock
covert willow
#

interesting

bitter dock
#

yeah lmao

#

imma try to put the problem pages in the groups aswell see if it still happens 1 sec

#

is it problematic to have 2 headers?

covert willow
#

kinda

#

but not from a functionality standpoint, just for valid html

bitter dock
#

okay so moving /signup into one of the groups fixes the issue

#

but theoretically if there ARE groups in a project, that doesnt require ALL pages to be in groups I thought

covert willow
#

That's my understanding

#

I mean

#

I don't have any that aren't in groups

young bone
#

just tried in a fresh project and no issue at all

covert willow
#

Hmmm its gotta be someting either tailwind config, next.config or tailwind config related

#

which version of next are you running?

young bone
#

is there any repo to check ?

bitter dock
#

latest

bitter dock
young bone
#

your project

bitter dock
#

not rn

#

I can copy the effected pages out and see if it reproduces then make a repo if it does

covert willow
#

That is really strange, I have a feeling that I might be able to find it if I could fine tooth comb through the files, but right now I am not sure what other questions to ask

bitter dock
#

im tryna recreate it in a new project rn, I'll let u know if I can do it

bitter dock
#

this reproduces the issue

covert willow
#

I will have to look at that in my local env in a bit

bitter dock
#

steps:

  1. go to localshost/login, then start the server. this will look as it should
  2. go to /page1 for example
  3. go back to login
  4. there should be no styling anymore
#

also pushed a change to put the root page.tsx into a group

also, noticed that when having a page.tsx in app/ aswell as one in app/(some_group), (whish you obvsly shouldnt) then navigating to localhost/, the same issue comes up where there is only raw html displayed. Could be a similar cause where somehow things are interacting in that same way when having groups aswell as non-group pages? idk

#

im new to nextjs so idk, but if you dont find the issue either I'd be curious if this is a bug with next itself

young bone
#

cant reproduce the issue

bitter dock
#

thats weird

#

why cant I send a video so that you can just play it direclty

#

1 second

#

there it is

#

btw the form error is already fixed and got nothing to do with the issue

bitter dock
young bone
#

yes

#

but I use pnpm

#

I dont think thats the issue

bitter dock
#

Ok

#

Thats.. weird. Yeah idk lmao

#

Guess I‘ll just put all my routes in groups and then its fine

young bone
#

what is your node version ?

bitter dock
young bone
#

can you try in other browser ? maybe an extensions that causes that on your side @bitter dock

bitter dock
#

no same thing on edge and operagx

#

also worth noting maybe that when I keep the server up, go once to page1 to trigger the bug, then switch browser, and on the new browser immediately go to /login, there is only plain html. So server side issue i guess

young bone
#

the thing is that I cant reproduce the issue so I guess is something on your side

bitter dock
#

yeah I suppose

#

but other than making a new create-next-app with dummy files, idk

#

end of the day its fixable by putting everything in groups so yeah

young bone
#

yes you can try with a fresh next app to see if the issue persist, at least we will know if it comes from the project.

bitter dock
#

i mean thats what I did