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.

Is there a way to import all components?

See original GitHub issue

I would like to do:

import * as MaterialUI from "material-ui";

To have all components accessible as properties on the MaterialUI object. Is there a way to do this or something similar?

Right now when I do that I just get an object with a colors property.

  • I have searched the issues of this repository and believe that this is not a duplicate.

Context

I am trying to create async wrappers for each component inside of my build system.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
oliviertassinaricommented, Mar 14, 2018

My bad, they are already enumerable: https://github.com/mui-org/material-ui/blob/caf5513c6f19d1b776801c96d1715b1dd1a6d1b0/src/index.spec.js#L11-L21

import * as MaterialUI from "material-ui";

console.log(Object.keys(MaterialUI).length); // 101
1reaction
oliviertassinaricommented, Mar 14, 2018

@ryanpcmcquen The uppercasing can be as good filter. You can prune all the lowercase modules. They will never be react components. But you can get some classes that aren’t component with an uppercase.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to import all components in React? - Stack Overflow
js file, import // the components you exported just the way you did it import NavBar from './NavBar'; import SideBar from './SideBar'; export...
Read more >
Import Components in React Like a Pro - The Startup - Medium
Hello Everyone! Today I'll show you how to import components in an efficient way. This will make your code more readable and concise....
Read more >
Importing and Exporting Components - React Docs
What a root component file is; How to import and export a component; When to use default ... Exporting and importing multiple components...
Read more >
Import All Components - Material Design for Bootstrap
Recommended way of optimization is to use modules. Importing anything from the compiled js file or even just the file causes all ui...
Read more >
Ad by Adclickersbot - Quora
Simplest way would be to import them all exactly like you suggested: import Blah1 from './components/Blah1.js';. import Blah2 from ' ...
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