-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
passing empty object to override palette
theme sub-object throws error
#12391
Comments
@bmueller-sykes Sorry, I don't understand. Could you explain in more detail your use case for writing such code: export const sykesTheme = createMuiTheme({
palette: {
primary: {}
}
}) |
Sure! The default theme is pretty complicated, and I doubt a developer is likely to remember each and every piece of it (I know I won't!). But imagine a developer knows she's going to modify the theme over time, so she looks at this page: https://material-ui.com/customization/default-theme/ ...and decides she's likely to modify the palette over time, but she's not quite ready to do so yet. But to prep for that, she creates her own theme, and does this:
...or something like that, so she can easily remember what the variables are when she's ready to go. I realize that she could just as easily do:
...which is why I said it wasn't that big of a deal. But, given that Does that answer your question? Thanks again!! The library is great!! |
@bmueller-sykes Thanks. What would you expect the library to do? Warn about it? |
If it were up to me, I'd say the library shouldn't do anything, except merge the empty object to the default object. I don't think a warning is necessary or required, since this might well represent a totally legitimate use-case. |
I disagree, it would require additional code and make type checking harder. I think that we should move with a better warning message. |
works for me! |
Expected Behavior
When creating a theme, I would expect that I could do this:
...and basically have nothing happen (e.g. the empty object overrides no default values, and everything works.
Current Behavior
Steps to Reproduce
If I create a theme like the above, I get the following warnings/errors:
Context
Obviously, this isn't an end-of-the-world issue, but I can see developers wanting to create empty objects in their theme files to help remind them of how a theme is structured, and then adding to that theme structure over time.
Perhaps this is working exactly as intended, in which case, close this and ignore.
Thanks!!
Your Environment
The text was updated successfully, but these errors were encountered: