-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
styled
gets empty theme values
#102
Comments
That result is correct. Look at the same example but with |
I am confused now. Is the empty theme expected behaviour? Then why does the So to reiterate:
I will admit I'm not entirely clear on how themes work, esp when only a few things are specified (e.g. in the example above I only specify |
This is a issue with Vite in develop mode (vitejs/vite#3301). In the past I tried to fix it, but no luck. The problem is that Vite reloads the context files when they are called from differents paths, so the theme context is recreated and its reference too. Now I know how fix it, thanks for report it. |
Closed via c5f7ab0. |
Thanks a lot! I will add "does the error only occur in vite develop mode" to my bug checklist :) |
See here for a demo. In short, a component like this:
will show an empty-ish theme value with many undefined keys (e.g.
typography
,palette
,shadows
, ...). However, if I build an otherwise identical component withuseTheme
like this:It will log an much more "full" theme value as I would expect. I do believe this is the behaviour we want. Here are both logs:
Interestingly, this bug seems to affect the second demo on the SUID docs on
styled
. The styled button does not appear becauseUncaught TypeError: theme.palette is undefined
.I've tried different versions of SUID/Solid but for some reason I can't find a combination that works. I've also tried explicitly setting a theme with
ThemeProvider
but that doesn't change anything to the "empty" theme values. I've also tested this on both chrome and firefox.The text was updated successfully, but these errors were encountered: