question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[typescript] Re-export Theme type in @material-ui/styles

See original GitHub issue
  • This is not a v0.x issue.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Context 🔦

Currently, to use makeStyles with Theme, I’ll have to use 2 imports:

import { makeStyles } from '@material-ui/styles';
import { Theme } from '@material-ui/core';

const useStyles = makeStyles((theme: Theme) => ({
  // ...
}));

I’d be great if I we can update the styles package so that it re-export the Theme type from core, because I tend to group similar components of material-ui into 1 import statement:

import { makeStyles, Theme } from '@material-ui/styles';

styles already uses Theme type from core, so I believe making a re-exports should not be a big problem.

Thank you.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:25 (21 by maintainers)

github_iconTop GitHub Comments

4reactions
eps1loncommented, May 9, 2019

We should just drop the breaking change. I can see no benefit and from my experience the whole @material-ui/styles vs. @material-ui/core/styles usage has only caused confusion.

I’m not sure some vaguely planned feature is a good reason to introduce a breaking change.

1reaction
eps1loncommented, May 8, 2019

We should just re-export the ThemeProvider from @material-ui/styles in @material-ui/core/styles. At this point I don’t think we should actually advertise @material-ui/styles if people are using @material-ui/core. At least I don’t see the benefit of importing from @material-ui/styles. If there is one we should document it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[typescript] Re-export Theme type in @material-ui/styles #15536
We reexport the styles modules with a default theme from the core. No, you most likely don't need it.
Read more >
How to use Material UI custom theme in React with Typescript
Material UI custom theme in React with Typescript v4->v5 migration guide. create separate file for declaration. theme.d.ts import { Theme, ...
Read more >
Breaking changes in v5, part one: styles and themes - MUI
This is a reference guide to all of the breaking changes introduced in Material v5, and how to handle them when migrating from...
Read more >
Material UI custom theme and TypeScript - Dragosh Mocrii
We use a mapped type CustomTheme to take the possible properties and their value types from our actual theme object. And we use...
Read more >
TypeScript and Material-Ui - Medium
My colleague had a TypeScript file for defining global color and font values, a material-ui theme module, and a material-ui styles file.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found