-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[typescript] Re-export Theme type in @material-ui/styles #15536
Comments
import { makeStyles, Theme } from '@material-ui/core/styles'; |
Thanks. So it means I don't really need |
We reexport the styles modules with a default theme from the core. No, you most likely don't need it. |
If I'm not mistaken, we need |
No, It's confusing me even more... I understand that |
The only difference is about the default theme. core removes the need for the user to use a theme provider at the expense of +3 kB gzipped. In the case of react-admin, you don't need to change anything. Import from core. |
But then I still need to import |
Why do you need a custom theme for? Imagine Material-UI was using styled-components, you would import the theme provider from styled-components. |
react-admin users typically want to set the theme of their admin. So we pass that theme to |
The code looks good to me. We have kept the MuiThemeProvider for backward compatibility but we don't document it anywhere. |
OK, so you confirm that I DO need to import both packages? // for when I want to use styles
import { makeStyles } from '@material-ui/core/styles';
// for when I want to define the theme
import { ThemeProvider } from '@material-ui/styles'; Since you reexport |
Yes. The boundary is drawn around material design. styles is agnostic to the specification. |
I understand the rationale of moving the styles to a standalone package to make things easy for those who just want styles and no mui components, but this shouldn't impact core users IMHO. Would you consider re-exporting |
You can rely on it. It's still unclear what we will do about it. |
Thanks for your help 👍 |
hmm it seems that TypeScript doesn't see this exported MuiThemeProvider:
The related code: import {
MuiThemeProvider,
createMuiTheme,
withStyles,
createStyles,
WithStyles,
Theme,
} from '@material-ui/core/styles'; |
We should just re-export the |
@fzaninotto Yes, the TypeScript definitions should be aligned with the implementation.
https://next.material-ui.com/guides/migration-v3/#styles @eps1lon What do you think of removing this point? My concern n°1 would be around what happens if we move to styled-components, do we still keep MuiThemeProvider? |
We should just drop the breaking change. I can see no benefit and from my experience the whole I'm not sure some vaguely planned feature is a good reason to introduce a breaking change. |
@eps1lon Sounds good 👍 |
Context 🔦
Currently, to use
makeStyles
withTheme
, I'll have to use 2 imports:I'd be great if I we can update the
styles
package so that it re-export theTheme
type fromcore
, because I tend to group similar components ofmaterial-ui
into 1 import statement:styles
already usesTheme
type fromcore
, so I believe making a re-exports should not be a big problem.Thank you.
The text was updated successfully, but these errors were encountered: