-
-
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
MuiThemeProvider theme prop no longer accepts function in TypeScript #9353
Comments
Yep, looks like the increased type safety afforded by #9295 exposed a bug in the typing of |
Sure thing @pelotom. Are we happy with the proposed type? I haven't thought too extensively about it, but seems like what we are after. Only gotcha will be for the top level |
At the top level you can still pass a function, it will just receive theme: Theme | ((outer: Theme | null) => Theme); |
This is a typing-only issue, so it can’t affect runtime behavior. |
For anyone stumbling here with an error like the following (because the above discussion has similar typings mentioned and make this result pop up on Google searches),
see #14431 (comment) |
Looks like after the change as part of #9295 we can no longer pass a function to the
MuiThemeProvider
component. An example of this can be seen in the docs at https://material-ui.com/customization/themes/#nesting-the-theme.It worked before because of the generic used here:
Perhaps the prop should be a
theme: Theme | (theme: Theme) => Theme
or something like that? Note the lack of the?
on the item. The theme is marked as required by the component, so the interface should reflect that.The text was updated successfully, but these errors were encountered: