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?]: global styles are removed when accessing routes #1191

Closed
2 tasks done
bigmistqke opened this issue Dec 27, 2023 · 3 comments
Closed
2 tasks done

[Bug?]: global styles are removed when accessing routes #1191

bigmistqke opened this issue Dec 27, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@bigmistqke
Copy link

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

Global style injected in root at app.tsx gets removed when accessing routes/subroute.
This happens both with ssr: false as ssr: true

Screen.Recording.2023-12-27.at.19.54.54.mov

Expected behavior 🤔

Global style to be preserved.

Steps to reproduce 🕹

Steps:

  1. make 'index.css' file with body {background: red}
  2. add 'import './index.css' file in src/app.tsx
  3. add <FileRouter/>
  4. add routes/index.tsx, routes/0.tsx, routes/1.tsx
  5. add <a href="./0"/> or <A href="./0"/> for route 0 and 1
  6. pnpm run dev
  7. switch between routes
  8. notice background changes from red to unstyled, and how in devtools css-stylesheat appears and dissapears

Context 🔦

No response

Your environment 🌎

No response

@bigmistqke bigmistqke added the bug Something isn't working label Dec 27, 2023
@bigmistqke
Copy link
Author

Localised the issue: it was due to some shenanigans I was doing with <FileRoutes/>

<Router>
  {
     (() => {
          const routes = <FileRoutes />
          ...
          return routes
     })()
  }
</Router>

I probably should be using import.meta.glob instead, or maybe a feature request would be a proper way to hook into FileRoutes definitions.

@nksaraf
Copy link
Member

nksaraf commented Dec 28, 2023

what do you want to do with the FileRoutes? You can get access to the raw routes defintions by importing from vinxi/routes (not documented but give it a try)

@nksaraf nksaraf closed this as completed Dec 29, 2023
@bigmistqke
Copy link
Author

the usecase was to get a list of routes to use it in a enu. I will give vinxi/routes a go!

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