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.

Mixing component import syntax breaks components in version 4.12.0

See original GitHub issue
  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

Lots of issues when mixing different import statement syntax in the latest release (4.12.0).

For example, when importing components using the import { component } from '@material-ui/core' syntax, and importing another component (for example a Table) using import Table from '@material-ui/core/Table' and setting the stickyHeader property to true on a Table component should make the table header… well, sticky but it doesn’t!

Expected Behavior 🤔

Setting the stickyHeader property to true on a Table component should make the table header sticky.

Setting a property on a component should work properly, regardless of the import statement syntax.

Steps to Reproduce 🕹

Steps:

  1. Import most components using the import { component } from '@material-ui/core'; syntax;
  2. Import a single component fully qualified: import Table from '@material-ui/core/Table';
  3. Watch things break

Example using Table, TableCell, TableBody, TableHead and TableRow components, setting the stickyHeader property to true on the Table component and it not working at all: https://codesandbox.io/s/sweet-water-gjq15?file=/src/App.js

Things are breaking if you inspect the table cells, having wrong classes in relation to the properties that are set on the Table component.

Here’s how to make it ‘work’ as intended: https://codesandbox.io/s/ecstatic-smoke-q2vz0?file=/src/App.js

There’s only a singular difference between the two examples: the import statement.

Context 🔦

Importing components one way or the other is generally something the IDE does for you, and since this is mostly automatic, sometimes the different import styles are mixed, and as such, with the latest version of MUI, you get lots and lots of issues when running your application. This issue is not exclusive to the Table component. From my limited testing, this issue also applies to Select components for example and I’m sure many more.

Your Environment 🌎

  System:
    OS: Linux 5.12 Fedora 34 (Workstation Edition) 34 (Workstation Edition)
  Binaries:
    Node: 14.17.0 - /usr/bin/node
    Yarn: 2.4.2 - /usr/local/bin/yarn
    npm: 7.19.1 - /usr/local/bin/npm
  Browsers:
    Chrome: Not Found
    Firefox: 89.0.2
  npmPackages:
    @material-ui/core: ^y => 4.12.0 
    @material-ui/icons: ^4.11.2 => 4.11.2 
    @material-ui/styles:  4.11.4 
    @material-ui/system:  4.12.0 
    @material-ui/types:  5.1.0 
    @material-ui/utils:  4.11.2 
    @types/react:  17.0.13 
    react: ^17.0.2 => 17.0.2 
    react-dom: ^17.0.2 => 17.0.2 

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:5
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
mnajdovacommented, Jul 7, 2021

It’s fixed in v4.12.1. Prove - https://codesandbox.io/s/gallant-http-khu11?file=/src/App.js Thanks for reporting and helping out debug the issue.

3reactions
ddolcimascolocommented, Jul 7, 2021

See #27149 Production builds are broken, too. @mui any update on this ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mixing component import syntax breaks components in ...
Lots of issues when mixing different import statement syntax in the latest release (4.12.0). For example, when importing components using the ...
Read more >
"Uncaught SyntaxError: Cannot use import statement outside ...
I got this error because I forgot the type="module" inside the script tag:
Read more >
Import Components from another file in React | bobbyhadz
The import/export syntax is called JavaScript modules. In order to be able to import a component from a different file, it has to...
Read more >
@material-ui/core | Yarn - Package Manager
Important: This documentation covers modern versions of Yarn. For 1.x docs, see classic.yarnpkg.com. Yarn.
Read more >
TACHYONS - Css Toolkit
Design Systems break as they scale (either scaling org or scaling product) because new components/variants of a component are introduced. Those variants ...
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