Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug?]: Using layouts with route groups at root level causes hydration errors #1582

Closed
2 tasks done
HansT01 opened this issue Jul 14, 2024 · 3 comments
Closed
2 tasks done
Labels
bug Something isn't working

Comments

@HansT01
Copy link
Contributor

HansT01 commented Jul 14, 2024

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

I'm trying to create a layout (base).tsx at the root level for the route group (base) with the following structure:

|-- routes/
    |-- (base).tsx   <-- layout
    |-- (base)/
        |-- index.tsx
        |-- about-us.tsx
    |-- admin.tsx    <-- layout
    |-- admin/
        |-- dashboard.tsx

Doing so causes a hydration error when rendering one of the pages in the (base) route group.

image

Expected behavior 🤔

No hydration errors, and everything renders as expected.

Steps to reproduce 🕹

Steps:

  1. Start a new solid start project
  2. Create a route group with a layout at the root level, similar to the one in the "current behavior" section
  3. Navigate to one of the pages in the route group
  4. Hydration error

Context 🔦

I want to create two different layouts for admin and non-admin pages. I want non-admin pages to be at the root-level, with admin pages under the /admin route.

I've read through the documentation for SolidStart routing, but it doesn't seem to address this caveat, so I am unsure if this is a technical limitation or just an oversight.

Here are route structures I've tested:

Hydration error:

|-- routes/
    |-- (base).tsx   <-- layout
    |-- (base)/
        |-- index.tsx
        |-- about-us.tsx
    |-- admin.tsx    <-- layout
    |-- admin/
        |-- dashboard.tsx

No hydration error, but no layout:

|-- routes/
    |-- (base)/
        |-- index.tsx
        |-- about-us.tsx
    |-- admin.tsx    <-- layout
    |-- admin/
        |-- dashboard.tsx

No hydration error with layout, but not root level:

|-- routes/
    |-- test/
        |-- (base).tsx   <-- layout
        |-- (base)/
            |-- index.tsx
            |-- about-us.tsx
    |-- admin.tsx        <-- layout
    |-- admin/
        |-- dashboard.tsx

Your environment 🌎

OS: Windows
node: v20.15.1
@solidjs/router: ^0.13.3
@solidjs/start: ^1.0.1
solid-js: ^1.8.17
vinxi: ^0.3.11
@HansT01 HansT01 added the bug Something isn't working label Jul 14, 2024
@HansT01
Copy link
Contributor Author

HansT01 commented Jul 14, 2024

Oops it looks like I hadn't tested on the latest versions. After updating everything, this now works as expected. Sorry!

@HansT01 HansT01 closed this as completed Jul 14, 2024
@mrlectus
Copy link

Oops it looks like I hadn't tested on the latest versions. After updating everything, this now works as expected. Sorry!

which example worked?

@HansT01
Copy link
Contributor Author

HansT01 commented Aug 16, 2024

Oops it looks like I hadn't tested on the latest versions. After updating everything, this now works as expected. Sorry!

which example worked?

Example provided under context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants